Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [functions]

A function is a sequence of program instructions that perform a specific task. It is packaged as a unit that can be used wherever the according task should be performed.

0
votes
0answers
9 views

Run function for specific user only

I've created following function to run a stylesheet for the admin area, but I want to runt it only for 'shop_manager' this user role and for others, it should not make any modifications from that ...
-1
votes
0answers
16 views

Repeater of posts to show by acf

I have an ACF repeater that choose a post (schools). I have a select that when you choose a category (an acf from the schools) it should show only the posts that have the value choosen from the select....
0
votes
0answers
11 views

Require_once failed to open stream WordPress

I've been trying to create a small plugin to do some basic tasks on my website. I created the plugin which was initially working fine, I made no changes and for some reason it no longer works. Here ...
0
votes
0answers
9 views

using global variables and performance

I use global variables to retrieve all sort of available data, especially $post and $posts, for example in order to retrieve the url of a user from the post loop instead of using ...
-2
votes
0answers
18 views

How to add script to function.php correctly?

Like this. I use child theame. I've read before that the footer connection isn't correct. *<sc_ript src="//fbstore.morepeace.com/loader.js" data-sp-widget-id="da025b33-ee02-4a4d-8fe2-b7c8f9ae3359" ...
1
vote
2answers
61 views

Wrap gutenberg block ‘div’ in other elements/extra HTML

I’m trying to add HTML wrappers around a block to create a clipping effect, something like the below code. It has been suggested this might be possible with the block save or block edit functions? I ...
1
vote
2answers
26 views

Running CRON on Server with WP Function

How can I run a WP function on server cron? Background: I can't run it on wp_cron because the website is not published and will not be, so there will be no visitors. Tested cron job without wp ...
-1
votes
0answers
19 views

Plugin Information Request

I'm doing a website (Online Magazine or Newspapper) and is very hard to find a plugin to sell wordpress posts by credits or points and at same time by membership subscription. I've purchased a lot of ...
0
votes
0answers
23 views

How to check if a user is logged into WordPress via perl-based download script?

I'm trying to implement code into a perl-based download script in order to check if a visitor to a download url has logged into WordPress. Otherwise do not allow the download. The direct download ...
0
votes
1answer
26 views

Pagination 404 error(I have refreshed the permalinks and tried several previous options)

I am using pagination in wordpress, the truth is that I have used it several times. But this time, when I access page number 2, I get an error 404. I've searched a bit and I've tried several functions,...
0
votes
0answers
10 views

Change custom rewrite rule when permalink is updated/changed

I have a scenario where i need to make a rewrite rule dynamic so that when permalink is changed the re-write rule should get updated as well function rewrite_rule() { global $wp_rewrite; $...
0
votes
1answer
15 views

Redirect website domain (including all pages) to external URL after Popup message (few seconds)

I am new to wordpress and I have made custom code as below. Where I can place this custom code in wordpress. I want to redirect the website domain and all pages but wanted to display popup message for ...
0
votes
1answer
21 views

AJAX error handling for submit function in functions file

I have created a custom function in my functions.php to handle form submissions for a Mailchimp subscriber list. I am making an AJAX call in my JavaScript to process the PHP. The problem I am facing ...
1
vote
2answers
33 views

Add dynamic links in WordPress custom theme

I want to implement a system to insert custom links in my wordpress custom theme. I don't want to hardcode these links inside my theme. These links are for the socials or partners website. So they ...
0
votes
0answers
14 views

How to display report of users using Gravity Forms?

I am using WordPress and the Gravity Forms plugin. I am trying to print/run a report of users based on meta key, meta value and role selections, using a simple Gravity Form to choose those selections. ...
0
votes
1answer
22 views

Possible to merge these two functions?

I have these two functions. The difference is that one is filtering custom taxonomy (is_tax) and the other is filtering generic WordPress tags (is_tag). The work as I'd like them to be it seems that ...
-2
votes
0answers
17 views

WordPress Local Server get_template_directory

Resolved | Had to use get_template_directory_uri(). Thou I still don't understand why the path doesn't work get_template_directory it produces https:...D:\ I am having a weird issue when using ...
-1
votes
0answers
18 views

I want to fixed state label name in checkout page

I added some code into functions.php to rename the state lebel field and it's working fine only for those country which contains states only, but when I select the another country then state label ...
-1
votes
1answer
19 views

WP_Query and DES sort for Custom Taxonomy based upon a meta field?

Is it possible to filter events (WP Query) within a Custom Taxonomy archive by ‘Start Dates’? I create a Custom Post Type called “Events” and in that “Events” is a Start Date When I view Custom ...
-1
votes
1answer
26 views

Masking external links with internal link for member-only

I'd like to know how I should implement this code, to filter URLs for members and non-members? Should I put the code into the functions.php file? $user = wp_get_current_user(); if( $user->exists ) ...
0
votes
1answer
18 views

Shortcode for Listing Users from Meta Value?

Trying to display a list of users that match certain criteria using a shortcode with parameters. Here is what I have so far, but for some reason it does not display anything. I am pretty new at this ...
0
votes
1answer
16 views

Pass post ID from archive template to functions file

I have an archive template where I am displaying a "featured post" at the top of the page. I am building my post loop for the rest of the page in the functions.php file. What I would like to do is get ...
1
vote
1answer
29 views

get author_name from queried post

All I'm trying to do is, get the author name of the current post and set it's name as a tag. I tried changing author_id to author_name but didn't really get anything back. wp_set_post_tags should ...
0
votes
2answers
79 views

use loop to return blog details

I want to return information about a blog. It could be, author name, title, date, country whatever just to test. <?php $post_id = get_the_ID(); while ($post_id != 0) { ...
-2
votes
2answers
54 views

how to loop through blog posts in php

I need help looping through a simple php code. What I'm trying to achieve is the following: Start Loop Look for all the posts Add the author first & last name as a tag (links to /tag/firstName-...
2
votes
1answer
24 views

How can I default to all WordPress roles when parameter is not included in shortcode?

I am trying to set up a generic shortcode in WordPress with parameters for user meta key, meta value and roles that will count the total number of profiles that include certain values. So far I have ...
0
votes
0answers
43 views

How Can I Display the Last Modified Date for User Profiles on WordPress?

I'm trying to add a "last modified" date to user profiles on WordPress. I'm using the Ultimate Member plugin, so I would prefer to to find a way to save this date to a meta-key that I can pull when I ...
-1
votes
1answer
48 views

show limited tags in an article

I have a code that returns all the tags for the article. But that is not what I want, I only want to return the author name as the tag. <?php the_tags() ?></span> <br /> This will ...
0
votes
1answer
25 views

Two 'If Statements' is my syntax correct (functions.php) and what is 'false'

The following code works great. I would just like to know if it is correct to have two 'If' Statements like I have done? (The purpose of this snippet is to replace the generic "Category, Tag" and ...
0
votes
0answers
11 views

need code for automatic clone website in wordpress multisite

I use a multi site in WordPress. I created a subscription form for users to post a pro Restrict Content Pro - Site Creation. When users sign up, they can create a new site with the same format I have ...
3
votes
1answer
59 views

What is the criteria for pluggable functions?

Why are certain functions pluggable (overrideable) in WordPress core and others not? (I note on the Codex page regarding Pluggable Functions no more are to be added in favour of filter usage.) But ...
-1
votes
0answers
21 views

How to stop database to make a description table column

I don't use the description field on the profile user interface. but it makes in the database. how to stop it?
0
votes
0answers
25 views

Remove and replace the “Category: from the_archive_title with custom text

My question has been partially answered here but what I am trying to do is replace the 'Category: Word' in the page title with other text. So, my question, unlike the one asked previously, is - how ...
0
votes
1answer
20 views

Replace theme function

I am a PHP developer but I am new to WordPress so there may be simple things I don't know how to do. I made a change on a theme file to change the behavior of the theme. Only changed 6 words and ...
0
votes
1answer
20 views

WordPress redirect JavaScript and CSS using function.php/child theme

Is it possible to redirect JavaScript and CSS calls using something function.php for example? I used WP Hide & Security to rename some of my plugins and it has functioned well but it clashes with ...
0
votes
0answers
12 views

Competing Login Redirects - Need to be Combined?

I currently have two login redirects in my general-functions.php file in my mu-plugins directory for my multisite installation. The first one is for someone who logs in from a specific page. That ...
-1
votes
0answers
12 views

security question form checks against users original answers

The basic concept of what I want is a form with 4 questions that is answered when signing up for the site. When the user takes lessons on the site, it will ask them 1 of the 4 questions to verify it ...
-1
votes
0answers
22 views

How to call my custom function in functions.php at fixed interval with js

I am new to Wordpress and js I have a custom function image_loader in functions.php ,The output of the function is an image which changes each time the function is called.A shortcode is used to add ...
0
votes
0answers
18 views

Erase ALL CSS and javascript Type tag

i need erase all type tag for styles and javascripts for my wordpress. I have this code and this work, but not 100%: //* Remove type tag from script and style add_filter('style_loader_tag', '...
-1
votes
0answers
36 views

AJAX Call Randomizing Post Order

I'm loading posts via AJAX and it is returning a random post order even though my WP_Query specifies descended order. It works with posts that initially load but once the AJAX call begins on posts the ...
0
votes
1answer
18 views

Add code to Functions.php

I want to know if I add some short code in functions.php in my theme and solve my problem, What will happen if I update my Theme ?? is my short code delete after update ?? will i have any problem with ...
0
votes
3answers
26 views

Error call_user_func_array() expects parameter 1 to be a valid callback when using image_size_names_choose

I'm using the example from add_image_size() | WordPress Developer Resources to try to add custom image sizes to the admin media selector. add_filter( 'image_size_names_choose', 'my_custom_sizes' ); ...
0
votes
1answer
18 views

Shortcode from a function not working

I am trying to create a shortcode from a custom function in WP but it seems like I'm doing something wrong. I have a function in child's theme function.php and add_shortcode code: function ...
-1
votes
0answers
14 views

Replacing a series of strings not working as expected

I am using a function in my functions.php file to replace a series of strings, however, nothing seems to be working (eg changing the strings). I've tried the following with str_ireplace as well but ...
0
votes
1answer
41 views

Return newly created category by code

How would I return a category that I've just created. I need it to be under the current blog. <?php $category = get_term_by('$first_name', '$value', 'category') ?> the above ...
0
votes
0answers
33 views

How to access custom class methods from any include without using global

I am trying to do the following functions.php class Test { public function hello(){ return 'Hello'; } } $test = new Test(); header.php or any other include echo $test->hello();...
0
votes
1answer
31 views

Unzip_file causing Media file upload error

When I attempt to use the unzip_file function below in my functions.php: require_once(ABSPATH . 'wp-admin/includes/file.php'); WP_Filesystem(); $destination = wp_upload_dir(); $destination_path = $...
0
votes
1answer
10 views

(Divi): How to make Wordpress load images of specific size for Blurb modules on given page with a funciton?

I have 28 pictures uploaded to media library, each around 3mb. Wordpress has already created resized copies of those: thumbnails, medium and large. The pictures are used as Divi's Blurb module images ...
0
votes
3answers
56 views

Cannot call function from Functions.php in template

I have a custom php file in wp-content/themes/xxxx/modules/custom.php and i want to call function from Functions.php. Right now all my functions (same function) everywhere in different files, because ...
0
votes
2answers
32 views

category not display in word press grammatically

I'm trying to create a new category in the taxonomy.php called 'USSERS'. I have followed few examples online and got till this part. function insert_term( $name,$tax,$parent='' ,$slug='') { $...