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
0answers
21 views

how a query can use local parameters in plugin function?

I've wanted to add a custom post type, so i've done a plugin to put on/off this post type. i have widgets inside the plugin in order to print posts with this custom type, that call more or less a ...
0
votes
1answer
30 views

Function shortcode - Set Parameter

function get_gifts_posts($params, $content){ $default_params = array( 'post_type' => 'post', 'order' => 'desc', 'orderby' => ...
0
votes
1answer
27 views

How can I add a Custom Button to Add or Edit post / page next to Add Media?

I'm trying to add a custom button nearby the Add media on the wordpress Add and Edit Post/Page. How can I do that? Thank you very much for your help!
0
votes
1answer
13 views

search form leads to 404

I'm using the follow code in my functions.php to add a search box to my primary nav menu - add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2); function add_search_box_to_menu( ...
0
votes
2answers
30 views

Override the Wordpress core function wp_referer_field

I'd like to override the core Wordpress function wp_referer_field to change the value of $referer_field variable inside of it. I've found that wp_referer_field is not pluggable and that I need to ...
0
votes
0answers
19 views

Slider Issues using MetaBox Plugin

I'm just now joining a previously launched project. The home page slider is a custom meta_box type from the MetaBox plugin. Here is the code to add the fields. $meta_boxes[] = array( 'id' => ...
0
votes
2answers
43 views

Display Custom Field Value on Admin Page Column

What I want is to display the value of the custom field called 'page_template'. I use the code below but it displays nothing under Page Template column although I have already defined a value for the ...
0
votes
0answers
89 views

Warning: Cannot modify header information - headers already sent by (output started at ../wp-content/themes/shopifiq/functions.php:1) [on hold]

I have just migrated my live site back to my local environment for further testing and development.I am running the site on OSX Mavericks with its stock Apache installation thus /Sites directory. As ...
2
votes
1answer
144 views

Different 'WP_CONTENT_URL' for different subsites in Multisite setup?

I host quite a few blogs on my network (WordPress Multisite) and have their static content served via a common CDN, by simply setting the wp-content directory URL in wp-config.php like so: # ...
0
votes
1answer
95 views

Add gallery id to rel attribe of wp_get_attachment_link

Now i have this snippet in my functions.php /** * Add rel to links. */ function add_rel_to_gallery($link) { return str_replace('<a href=', '<a data-fancybox="true" rel="group" href=', ...
0
votes
1answer
32 views

how to edit functions.php in a child theme

I am using wordpress for my site. I am using a theme called esplanade. I have made a child theme folder and created a style.css with the required lines in it. My child theme is working nicely. I have ...
0
votes
1answer
40 views

Is there a way to prevent a function/method from being called outside a specific hook?

I would like to make function only callable by a specific action, in this case the register_activation_hook() function. How can I do this?
0
votes
1answer
19 views

Add unique id to Preview URL

Is there an easy way to append a unique ID to the preview URL when the preview button is clicked by a user? So this: http://example.com/news/1/title/?preview=true Becomes: ...
0
votes
0answers
39 views

Update all posts in one go

I've just used the woocommerce CSV uploader to add 1000+ products to an online store. However the products only appear in the store after they have been updated - And it has to be from the main edit ...
0
votes
1answer
36 views

theme options not saving

I've created a really simple theme settings page to just enable my user to add some social media links. However when I input some data and save the fields the text vanish's and doesn't seem to save. ...
0
votes
1answer
24 views

Calling directories to load in wordpress

I have a wordpress install, with two sub folders "assets" and "functions" these folders contain important files for the wordpress theme. What would be the best way to load these files I've tried ...
1
vote
0answers
78 views

Woocommerce - sort by discount in dropdown menu - woocommerce_get_catalog_ordering_args [on hold]

I have searched and searched for a solution for adding a "Sort by Discount" to the dropdown on the shop page in woocommerce. I need to add a calculation such as this somewhere: $percentage= ...
3
votes
2answers
143 views

Replacing Icons in the Dashboard

Is there a way for me to replace the icons in the WordPress Dashboard with custom ones? I'm imagining there's got to be a way to do this with the functions.php or, more ideally, with a custom-built ...
0
votes
2answers
27 views

Dequeue scripts in IE7 only using functions.php

Is it possible to dequeue scripts in IE7 only using functions.php? I have my scripts configured in the following way: // JS function scripts() { // Register scripts & styles ...
0
votes
0answers
27 views

how to echo script in head from plugin options page via textarea?

I know how to echo in the head but when i paste a script in the textbox in my options page it comes out like this: &lt;script&gt; ...
0
votes
1answer
37 views

How to change menu order item

Hello I have a main menu in my website Home | How to start | about | contact | categories but I add one item that lists all categories in functions.php add_filter('wp_nav_menu_items', ...
0
votes
0answers
16 views

Template tag for custom field sub heading in post - error

Im trying to create a template tag for a subheading for a post which is entered as a custom field. This is the function I have: function spost_subheading() { $key = get_post_meta($post->ID, ...
0
votes
0answers
25 views

Using a Multi Site Users Blog ID as a WP Prefix

I'm trying to update a plugin so that the prefix for the defined tables is taken from the ID of the posts authors site This is what I am trying to do at the moment function { global $authordata, ...
1
vote
1answer
47 views

How to overwrite youtube embed?

I really like how you can just paste a URL right into the post... such as: http://youtube.com/watch?v=xyz or http://vimeo.com/123456 What I want to do is change the default code for this to support ...
0
votes
1answer
44 views

Metabox Data not saving

My Metabox data doesn't appear once I've saved the page, I tried vardump() on both getextra_mbe_date and getextra_mbe_time which returned null my code is <?php /* Plugin Name: Events CPT Plugin ...
1
vote
1answer
133 views

Super simple shortcode not working

Have been looking at various tutorials and answers here and elsewhere and just can't get this to work. Just trying to display a simple output from a shortcode as below, but it is just outputting the ...
0
votes
0answers
14 views

Scheduling a function to change meta value for every post within query

I am trying to check if a post (custom post type) is equal to or more than 14 days old. If it is, I want to change the meta value 'listing_status' from 'active' to 'inactive'. I want Wordpress to ...
0
votes
1answer
24 views

laoding bloginfo url in function array?

I'm using wp customizer in a theme and I want to load a page using a link in admin bar. Link in admin bar is added, and link format is like this: ...
0
votes
0answers
32 views

change profile icon name buddypress

I am using wordpress version 3.8 and buddypress version 1.9.1. In profile page there is icons like Notifications, Activity, Groups etc. I am trying to rename the icons for example "Groups" to "My ...
0
votes
2answers
98 views

Conditionally write open graph meta property in header

Have a function I use to print Open Graph tags in the header of each page I also have a plugin I use to post to Facebook which also puts in it's own set of basic OG Tags. Facebook doesn't like if a ...
0
votes
0answers
43 views

WordPress Visual Editor Filter for Visual View

I have setup custom HTML to be created when a user inserts media using "Add Media" in WordPress using the code below: add_filter('get_image_tag', 'add_image_frames', 10, 6); function ...
0
votes
2answers
206 views

How do I change/modify the_post_thumbnail(); html output?

I'm working on building out a custom theme and have been struggling with this one for a bit. I am trying to modify the HTML output of the_post_thumbnail(); function. I need to do this because I am ...
0
votes
0answers
110 views

Count Checked Checkboxes in Contact Form 7

I've built a form with Contact Form 7. The form is a petition. It has a list of checkboxes with names and email values attached to them. If a name is selected, that email is added to the list of ...
0
votes
1answer
101 views

How to redirect users to custom lostpassword page?

How to redirect users to custom lostpassword page when they click on the Error: Lost your password?. Because I set a redirect for wp-login.php to my custom login page. when a user click on Error: Lost ...
-1
votes
1answer
21 views

Error in php code

I was following the Book building wordpress theme from scratch. An options page is created through this method in the wordpress admin panel . There is an error present due to which nothing appears ...
0
votes
1answer
21 views

loginout function customization

I want to make login / logout function inside my header to display when the user is logged in Logged in as,{user name} where {user name} should be wrapped inside an anchor tag with a custom permalink ...
1
vote
1answer
214 views

Display Total Number of Social Shares

I have to display the total number of social shares, like mashable does in it´s website. It´s not a problem, I found a php code that does the job. function getTotalShares($atts) { ...
0
votes
1answer
37 views

WordPress add post format support not working

I am working on a theme and for some reason, add_theme_support( 'post-formats', ... ) is not working. In my theme's functions.php I have the following near the top: function mytheme_setup() { // ...
0
votes
0answers
53 views

Add image caption to frescojs

I want to add the image caption to the frescojs popup. The following code is in the functions.php: add_filter( 'wp_get_attachment_link', 'sant_prettyadd', 10, 6); function sant_prettyadd ...
4
votes
3answers
121 views

How to restrict actions and filters “properly” by conditions

Which one is correct when adding actions/filters/etc.... Both methods work fine and I've seen people do things both ways, but I'm assuming one is correct. My gut tells me that wrapping the if ...
0
votes
1answer
60 views

Get author meta of all writers

We know from the docs that you can get an author's meta like so: <?php get_the_author_meta( $field, $userID ); ?> But I would like to have a custom "About us" page which displays all the ...
0
votes
0answers
27 views

Strip <p> on get_the_content_limit

I would like to remove the paragraph tags < p > it generates, i tried adding strip tags but it doesn't seem to work. function the_content_limit( $max_characters, $more_link_text = ...
0
votes
0answers
36 views

How to define a product on sale on WooCommerce programmatically [on hold]

how are you? I'd like to define a WooCommerce product on sale programmatically, just using function.php and having the ID of the product. I did some searches in the WooCommerce documentation but it ...
0
votes
2answers
56 views

Echo string and function?

I'm trying to get "string of text: Edit" <?php echo 'string of text: ' . edit_post_link( 'Edit' ); ?> but this outputs "Edit string of text:" How do I make it appear in the correct order? ...
0
votes
1answer
40 views

send email to all registered users when post expires

I have a function which, when a post is published inside a CPT after three days the page is redirected to another URL/PERMALINK. This is the code: add_action('template_redirect', ...
0
votes
1answer
14 views

Function to erase every post from a taxonomy

I'd like to have a piece of code that erase every single post from a taxonomy of a post type when triggered. How can I do it? Thank you.
0
votes
2answers
22 views

Expected 'add_filter' (T_STRING)

I am trying to add a filter for get_avatar so I could implement an avatar alignment but when I do, I received expected 'add_filter' (T_STRING First Approach add_filter('get_avatar', ...
-1
votes
1answer
30 views

reusing code in function and running it with loop

In variable.php , the page use to display any attributes related to a product. I want some changes in code but not for all pages, so i think only point it to create a function of variable.php, and ...
0
votes
1answer
44 views

Include a file that has a function in it

I am using include 'filename.php' to load a php file into a template file, simply because the original PHP template file was getting huge and I wanted to split up the sections into different files for ...
0
votes
2answers
200 views

How to redirect non-logged in users to a specific page?

How to redirect non-logged users requesting for a specific page/URL to another page/URL and display a message like "for members only". I know its quite easy to code using !is_user_logged_in() ...