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
3answers
572 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
499 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
772 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
808 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
459 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
20 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 [on hold]

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
573 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
34 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
465 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
12 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
13 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
23 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
18 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
20 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
770 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
138 views

woocommerce change currency per category [on hold]

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
854 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 ...
3
votes
1answer
53 views

Pagination adding page-numbers dots when using 'mid_size' => 0

Hey all, I'm attempting to do convert my current pagination: from : Prev 1 2 3 Next to: Page 1 of 2 --> My current code looks like this: if( ! function_exists( 'my_pagination' ) ) { ...
0
votes
1answer
831 views

Remove Header and Footer in iframe

Many people embed my website's pages in their websites as iframes. I want them to don't take my footer, header and a specific division in those iframes. Since, footer, header and mentioned specific ...
1
vote
3answers
46 views

How to reduce original image quality on upload?

I know that I can use the jpeg_quality filter like this: add_filter('jpeg_quality', function($arg){return 75;}); This will reduce the image quality of the images generated during the upload process ...
0
votes
2answers
419 views

Shortcode to find and replace URL

I'm trying to create a shortcode that will search within some specified text for a link and replace it with one that I specify. For example: [scode]Click on <a href="www.X.com">this ...
-2
votes
0answers
24 views

Changing Pagination Numbering in Genesis Framework [on hold]

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
520 views

Change custom post type slug from plugin options

I'd like to give users the option to change a custom post type slug in my plugin. Using this answer, I'm able to hardcode it into a function: Redeclare/Change Slug of a Plugin's Custom Post Type ...
0
votes
2answers
31 views

Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?

This is my first go at making my own shortcode. What I am trying to do I have 11 different outputs for star ratings I want to be able to use in posts. I want to wrap it all into one shortcode, and ...
0
votes
1answer
2k views

Let users upload image(s) to the post from front end

I want to enable logged in users (Wordpress) to submit posts from front end (among with other data). My form is working great, I add custom post meta data which I later display on custom post page. ...
3
votes
1answer
8k views

Add container to nav_menu sub menu

Is there a way I can wrap a div around wp_nav_menu's ul.sub-menu So for example the markup would go from <ul class="menu"> <li><a href="/">Item 1</a></li> ...
3
votes
1answer
77 views

How to get the registered sidebar's name by its id?

Let's say I have this code in my "functions.php": function mytheme_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar Name', 'mytheme' ), 'id' ...
0
votes
0answers
20 views

Function to change text with <br> tags into Unordered List

I've tons of product pages in Woocommerce where product info was bulk imported using CSV file. Now, all these hundreds of pages carry <br> tags for 'features' - which I want to change to ...
0
votes
0answers
32 views

taxonomy child term url change

Currently I have custom taxonomy called "client_categories" under custom post type "press_centre" I want to change url from www.mysite.com/clients/client1/image_library_1/ to ...
0
votes
0answers
15 views

Removing commercial theme's custom autop on specific pages via functions.php

So my problem is with using the custom theme Karma at http://themeforest.net/item/karma-responsive-wordpress-theme/full_screen_preview/168737 Great theme.. except it removes the default ...
1
vote
1answer
1k views

Only let plugin add actions to wp_head & wp_footer on single posts

I'm using a a plugin (Comments Evolved) on a recently built site. The issue I'm having is that this plugin globally enqueueing and adding actions to the head and footer of all pages. I'd like to ...
-1
votes
0answers
18 views

Table of content in sidebar of Paginated posts

I am trying to work out a way to display an automatic table of content for paginated posts. I want to display it in a side bar widget and make the widget sticky to go down when the visitor scroll ...
0
votes
1answer
26 views

Warning: call_user_func() expects parameter 1 to be a valid callback, function

I keep getting this error when. I am trying to insert a dashboard widget and I don't know what's causing the error. Warning: call_user_func() expects parameter 1 to be a valid callback, function ...
0
votes
0answers
16 views

Help removing post images older than X days

I need to remove images in posts older than a set amount of days. I feel like my code should work but it does not and I do not know why it doesn't. My website, when this is added in functions, ...
1
vote
2answers
35 views

wp_enqueue_script + wp_enqueue_style Since When

wp_enqueue_script + wp_enqueue_style: these 2 are recent inventions in wordpress are they are from many years. I purchase a course from udemy his authors hasn't used these functions. His videos look ...
261
votes
108answers
131k views

Best Collection of Code for your functions.php file [closed]

Please vote on the question and any answers you find useful by clicking on the UP arrow on the left hand side of the question or answer. As with many others who are now viewing this post, I have been ...
0
votes
1answer
13 views

Post Custom & Taxonomy 404 error

Basically the single Permanent link are giving me 404 errors. might be wrong? Code is below: function post_types(){ register_post_type('carta',array( 'labels' => array( ...
4
votes
1answer
47 views

Preferred Use of home_url()?

This isn't a problem but rather I am just curious to see how others are using this function. The codex does not really say a preferred method of use although it does provide some straight-forward ...
0
votes
0answers
12 views

Unhook (or remove) Sidekick Customizer Option using a function

How do I remove / disable / hide the "Click for Help" Sidekick Drawer? I'm reading over the codex and I just don't see anything relevent between this and the plugin. I downloaded the plugin, start ...
0
votes
2answers
634 views

Show the post date using the wp_get_archives() function?

I have some doubt about the wp_get_archives() function In my website I have create the following page template that use the wp_get_archives() function to show the posts list: <?php /** ...
1
vote
2answers
644 views

Update user meta of author when post content is viewed

I have a value that I'm trying to store as user meta for authors on my site. I need it to update itself every time the content of a post is viewed for that author. Here's as far as I've gotten but it ...