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.

learn more… | top users | synonyms (2)

0
votes
1answer
1k views

Session is not starting

I've read the usage of session() in WordPress from here and here. And I placed the following code into the very starting of my functions.php: /** * ENABLING SESSION TO THE SITE * Thanks: Shazzad ...
-3
votes
0answers
18 views

Wordpress Woocommerce Related Products [on hold]

I would like to move the Related Products on the Products page to a lower position with a full width column, so I have defined the following in the functions.php file to do just that; // Move related ...
2
votes
0answers
28 views

Efficient coding: how to keep track of function stack?

I've written a plugin that calculates how much server time is required for each function in a theme or plugin. The idea is it will encourage developers to write efficient and green code. If you want ...
0
votes
1answer
26 views

How to customize search result page title?

I would like to customize the page title of the search result page: from: <title>Search Results for “search string” – Page 2 – Sitename</title> to: <title>“search string” result ...
1
vote
1answer
455 views

Current path on page in functions.php

How can I get the current path of my page? I know how to do it inside a template file, but I need it inside functions.php. And it has to be before the send_headers hook, because I'll use this info to ...
0
votes
4answers
52 views

How to filter out shortcode when displaying the_excerpt() in the loop?

I'm using the_excerpt() in my template loop to display post excerpt on the front page. It's currently displaying unwanted shortcode directly on the front page eg. [box]post content[/box] ...
-1
votes
0answers
8 views

Schedule price variation for Woocommeece

i'm creating a travel ecommerce with wp and wc (not other plugin) and i need to setting a schedule price. I create a standard product and Then create a new label name "schedule" add_action( ...
1
vote
2answers
33 views

Two functions.php files in one theme

I am creating a WordPress Framework and within it there is the standard functions.php file. I will create new themes based on the framework which will use the framework functions.php file but have ...
0
votes
1answer
10 views

Wordpress add css class to cloud tag anchor tag

How to add CSS Class to ul and anchor element of Tag Cloud generated through wp_tag_cloud function. I want wordpress default class for ul 'wp-tag-cloud' to be 'tag-cloud' and anchor tag would have '' ...
27
votes
5answers
34k views

What's the difference between home_url() and site_url()

My understanding is that site_url() returns the location where the wordpress core files are. So, if my blog is hosted at http://example.com/blog then site_url() returns http://example.com/blog But ...
2
votes
1answer
290 views

Need help setting default setting value for radio button in theme customizer

I need help figuring out how the radio button saves it's value in the theme settings. In my theme I added Radio buttons in the theme customizer. So far they are working great. Although I have one ...
0
votes
1answer
14 views

Suggest Users basing on User taxonomy

My question is for getting informations or directions about how to move for a task I have to do. This is just a request for advices due to the fact I'm not an expert in wordpress development. My task ...
1
vote
0answers
23 views

Use author author display name in permalink structure for pages and posts

I need to add the author name as a subdirectory prefix for all user's posts and pages. For example: example.com/johndoe/ //The author page for John Doe example.com/johndoe/category/test-post/ //Test ...
-1
votes
1answer
20 views

WooCommerce - Getting variation ID from attribute values

I am building a WooCommerce store and am adding variable products to the cart programmatically after submission of a Gravity Form. I am getting the data from the form and includes the product_idas ...
-3
votes
0answers
41 views

Changing Pagination Numbering in Genesis Framework [closed]

Due to some requirements in the content I publish on my website, I need to change the pagination numbering from 1 2 3 4 to 0 1 2 3. I need to find a way to decrease the ID of the paginations to ...
0
votes
1answer
14 views

Adding an interior 'hero' area with some added php title customization

Ok here it goes. I hope Im at the right place. Sorry if this has been answered I looked over on the regular SO but couldn't find an answer. I'm currently building WP site that has a slider area on ...
1
vote
2answers
1k views

Execute a shortcode when clicking on a image

I asked this in stackovorflow under javascript and was informed not possible so I trying here I have a shortcode for a opt-in form and I want it to pop up when a image is clicked I tried the ...
0
votes
1answer
24 views

Translating string in Woocommerce Cart [on hold]

I usually don't have trouble translating WP and it's plugins for my customers, but this one string is driving me nuts. In the cart there is this line that tells the included tax next to Totals. For ...
0
votes
0answers
11 views

Category specific attribute

I wonder what is the best way to define specific attribute for category. My idea is following. I have some categories that are just wrappers, they don't contain any post so they are only parent ...
-6
votes
0answers
22 views

Woocommerce: Adding my own slider as a Product slider [on hold]

I want to add my own slider as a Slider for my products. Available plugins aren't really nice. So, I have my query and a slider, I'm just not sure where to edit it in Woocommerce... Any help?
0
votes
1answer
11 views

How do I routinely extract the thumbnail of the most recent post?

I would like to write a PHP snippet that can communicate with Wordpress. When a new post is published, a file today.jpg will be generated from the thumbnail url (a custom field) of the most recent ...
3
votes
0answers
87 views

How to override a function when isn't at functions.php

I am trying to override a function for a theme in the child-theme but I can't get it to work. At functions.php on the theme I can see this require_once line: ...
3
votes
3answers
7k views

Get the blog page URL set in Options

I have set the blog to be a different page other than the home page. I want to have a link from single.php to this blog page. Is there any function that pulls out URL for the blog ?
2
votes
3answers
1k views

How to display post tags

I'm converting an HTML template into a wordpress theme and I'm having some trouble displaying the post tags within the functions.php file. What I would like to do is add the following code into the ...
0
votes
3answers
577 views

Passing postid of Testimonial Custom Post in Shortcode Parameter

I am trying to create Testimonial custom post and display using shortcode function create_post_type() { register_post_type( 'testimonials',//new post type array( ...
0
votes
1answer
502 views

Custom wp_trim_words() function not trimming right

I have this custom wp_trim_words() function set to give me excerpts of only 20 words, and for the most part, it works fine. Except for some reason, on posts that contain lists, it outputs way more ...
0
votes
1answer
781 views

How to add nav menu items to a specific position within a menu

I'm adding login/logout links to a nav menu using the following code: function rp_add_login_logout_links( $items, $args ) { $link = wp_loginout( get_permalink( get_option( ...
0
votes
1answer
818 views

Add content after get_header

I'd like to add content directly after the div#main (end of header.php) and before /div#main (beginning of footer.php). I'm using an own child-template (of twentythirteen), that contains only ...
0
votes
1answer
463 views

How can I customize the size of the header of my theme?

I want to change the size of my header using the Sparkling theme. In functions.php, right below this: /** * Implement the Custom Header feature. */ I added this: add_theme_support( ...
0
votes
1answer
13 views

get_page_templates only return templates with “home” in the filename

I have the following custom page template filenames: template-about-1.php template-about-2.php template-home-1.php template-home-2.php I have this function to get_page_templates: function ...
0
votes
2answers
23 views

Which function required?

Which WordPress function allows you to include the footer.php file into index.php file?
2
votes
1answer
1k views

Using PHP to toggle stylesheet and header image, set in cookie

I haven't done a lot of work with cookies or Wordpress before so I think I've been a bit over-optimistic in my quest :p I have created two themes for my site, night and day. I would like the user to ...
-1
votes
0answers
13 views

Edit woocommeerce checkout form on the fly [closed]

I'm using woocommerce in wordpress and i'm planning to change the checkout form depending on the action of the user. I have the standard form created in the admin checkout fields settings. That should ...
0
votes
2answers
574 views

Custom registration form in shortcode getting internal server error 500

I created a custom registration form which works fine when used as a custom page template. I needed it as a shortcode so I created a shortcode using the function below /* Custom shortcode */ function ...
1
vote
1answer
36 views

Wait a result before enqueue

Supposing we have : class AwesomeClass{ private storedResult; private __construct(){ add_action( 'set_logged_in_cookie', array($this, 'a'),10,1); ...
0
votes
1answer
22 views

previous_post_link inside of a function?

I'm missing something on how to call previous_post_link() inside of a function. I also tried assigning the output to a string variable and using that. function prevnext( $content ) { $content .= ...
0
votes
0answers
22 views

function to write the output of a variable + post_title in post_content

I have a function that writes the output of a function of a rand_keys + the post_title in post_content, but writing the title but only happens after I click manually on the update button on the ...
0
votes
1answer
10 views

add_action wp_enqueue_script priority level only works for admins

I have a function in my functions.php file that loads all of the scripts into the header for my website. The line to run the function was like this: add_action('wp_enqueue_scripts', ...
0
votes
2answers
473 views

Passing variable as add_shortcode argument

I'm trying to pass a variable into the add_shortcode function to be used as the shortcode name but it does not seem to be working. Is there a way that I can pass a variable similar to this? foreach ...
0
votes
0answers
16 views

How to Publish a Post Multiple Scheduled Time

I want to publish a post in WP, but not immediately. So what I am doing is like this- From this tutorial. So, I am getting only 1 time when the post will be published. But I want to the post be ...
0
votes
1answer
18 views

Adding bootstrap classes to video shortcodes

I want to make videos responsive... There is a function in /wp-includes/media.php file: line 2497: $html_atts = array( 'class' => apply_filters( 'wp_video_shortcode_class', ...
0
votes
0answers
24 views

Update custom fields after updating related custom field

I have a custom post type that I'm filtering by a custom field, I then select one of these posts & update it in the front end. But when this is updated, I need to also update the other filtered ...
0
votes
0answers
20 views

Display most popular posts

I have already found a way to display recent posts: <?php $args = array( 'post_status' => 'publish', 'numberposts' => '60', ...
0
votes
2answers
22 views

Passing stored variables to add_filter

I am working on a site where the page titles are generated dynamically from external data sources. So obviously, Yoast SEO/WordPress SEO doesn´t know anything about the correct title, description, ...
0
votes
1answer
771 views

Load post attached images on a single page site with fancybox

I'm trying to make a single page site that will display posts as thumbnails in some part. Then if a thumbnail is clicked, I want all the images contained in this post to be loaded with fancybox while ...
-1
votes
1answer
26 views

Using a filter in functions.php to add content to single posts regardless if post is in main or child category

Im using following filter (codex) to add some html content with a lower priority (20) to the bottom of my single posts wich are in a specified category: add_filter( 'the_content', ...
3
votes
2answers
7k views

Using wp_get_nav_menu_items() to list children of children pages

I'm working with a Genesis Based Theme and I'd like build a Page/ Child Page menu structure. That part I can do with the help of some code produced by Bill Erickson. Essentially what I'm trying to do ...
1
vote
1answer
140 views

woocommerce change currency per category [closed]

I am trying to display a different currency on a specific category within my Woocommerce store. Specifically, this category is full of items that can only be purchased through myCred points. The rest ...
2
votes
2answers
857 views

Using plugin functionality in external php script not working

I am encountering a strange problem which I couldn't solve so far. I'm calling a .php script via cronjob (Debian/GNU Linux). To use wordpress functionailty I added: define('WP_USE_THEMES', false); ...
0
votes
0answers
24 views

Where to place functions and actions if functions.php is encoded? [duplicate]

I've got an encoded theme but I need to run this function on every post status change. So I don't know where to put this code cause function.php is encoded. I am using this function on another theme ...