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)

1
vote
1answer
223 views

Auto Populate Custom Field with Complex Value That Increase by One?

Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 PO - ...
1
vote
1answer
50 views

How to assign classes to all elements?

Is it possible to assign classes to elements of certain type? For example, all paragraphs in the post body or comment body should have class="paragraph", all unordered lists in post body should have ...
1
vote
1answer
58 views

Force authors to Preview a post before publishing

I'm looking to find a way to force authors (including admin & editors) to preview their post before publishing. Is this possible, if so does anyone know the easiest way to achieve this? I'm ...
1
vote
1answer
71 views

media resize/crop possibilities?

Under admin panel -> media settings there are no minimal width option for thumb or other image modes ex: I would like to crop image widthout distortion -> height 124px and minimum-width 124px and ...
1
vote
1answer
422 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
vote
1answer
85 views

WordPress Automatic Filename Changer

So I used this function that allows me to change the literal filename in the directory on upload. But, it doesn't actually change the filename, hence changing the slug to the ID when attaching to a ...
1
vote
1answer
75 views

Post meta not updating

I am trying to make a voting system for WordPress. This is my code in functions.php: add_action("wp_ajax_add_votes_options", "add_votes_options"); add_action("wp_ajax_nopriv_add_votes_options", ...
1
vote
1answer
242 views

Changing post category from dropdown

I am showing a list of posts on the front of my wordpress site which each have a dropdown next to them with a list of category's, which are pulled in as follows. As you can see the form submit button ...
1
vote
1answer
61 views

Want to be able to sign up subscribers as authors

I want to be able to select a subscriber an author of a post in the admin so it displays their name as having written the post, but I do not want to give them any additional privileges (if they login ...
1
vote
1answer
647 views

edit role display name and label name without plugins

I'am creating WordPress function for editing role name function change_role_name($role_name, $new_role_name, $display_name) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles ...
1
vote
1answer
48 views

Run wp_kses_decode_entities on atom feed?

I would like to convert the htmlentities in only my atom feed to their corresponding characters. Using the below in my functions.php I've gotten close, but obviously the commented out line doesn't ...
1
vote
1answer
207 views

Wordpress metaboxes - textfield suggestion automatically populated

[Long story short] Is there any Wordpress plugin/function that would allow the creation/integration of a metabox's textfield that automatically populates a dropdown menu (in the admin area, while in ...
0
votes
1answer
22 views

Deactivate a plugin on wp version

I've creating a theme options page at the moment and was playing around with this function deactivate_plugins() I'm running wordpress 3.8.3 so running this code in my plugin should uninstall it. ...
0
votes
1answer
34 views

Is there a WP function to get taxonomy name from taxonomy_term_id?

I need to get the taxonomy name from the taxonomy_term_id. I am currently using the following to get it: global $wpdb; $term_taxonomy_table = $wpdb->prefix . "term_taxonomy"; $taxonomy = ...
0
votes
1answer
56 views

Display Buddypress notification bubble on single menu

I am trying to get the Buddypress notification bubble to appear in one of my two navigation bars. I was given this code to place in my functions.php which does everything, except it displays in both ...
0
votes
1answer
62 views

Strange error from functions.php files (wp_register_script)

I'm trying to migrate a wordpress site, and i'm receiving this error when debugging on the new server: Notice: wp_register_script was called incorrectly. Scripts and styles should not be registered ...
0
votes
1answer
60 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
1answer
42 views

Modify function Shortcode_atts

function get_date_posts($params, $content){ $default_params = array( 'post_type' => 'post', 'order' => 'asc', 'orderby' => ...
0
votes
1answer
63 views

How to load jQuery in the footer - nothing works for me

I tried all the solutions I found on the internet, including the ones I found here, but nothing works on my theme - jQuery always load in header. I try to use the one from Google, but I would be happy ...
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
36 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
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
28 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

save_post not working

In order to create (or update, whenever a post is updated) a unix-timestamp meta, I used following code to fire on save_post. I pasted this code in functions.php. But I believe this is not working, ...
0
votes
1answer
40 views

Pull random comment from specific post, display on homepage with shortcode

I'm trying to display a random comment from specific posts on my homepage, using the solution that was provided here: ...
0
votes
1answer
27 views

Overwriting a Shortcode

I have a theme that extends the Visual Composer plugin with a slider on the front page. The slider will show five testimonials from five different customers. I want to add the featured image of each ...
0
votes
1answer
25 views

how to exclude in sidebar

I following insert adsense code. but post is less than count ,adsense appear to sidebar widget. how to exclude in sidebar? add_action( 'widgets_init', 'wpse_84250_register_ad_widgets' ); ...
0
votes
1answer
53 views

adsense code showing on random post thumb

I've followed the guide below, but have made a few edits to it and now i need some help: Add Adsense code in index.php I removed the following line from my code if ( ! is_front_page() ) return; and ...
0
votes
1answer
37 views

Unable to add extra elements to the main navi (wp_nav_menu_items)

I'm trying to get the list of authors to automatically appear on the main navi (without having to manually add them one by one as they are created). So far I added this on my functions.php, but no ...
0
votes
1answer
42 views

Get post title by Alphabet

I try to call this function to get a list of posts by alphabet. But for some reason i keep getting an error. Call to a member function get_col() on a non-object. What am i doing wrong? {function ...
0
votes
1answer
28 views

Retrieving Login Data from Woocommerce and Putting it into a Form

So my goal is to try and retrieve the data from the account a user logs in with. e.g name,age, address and place this within a contact 7 form. So there name, age and address will appear already ...
0
votes
1answer
12 views

User's Comments Number: Storing it in a meta field for different uses

As I am building a new website where tracking users' information is key to engage, etc..., I found it important to be able to store users' number of counts as a meta. The main reason for storing the ...
0
votes
1answer
27 views

Trying to see if page is category or single and displaying title with appropriate heading tag

I'm using a custom theme from ThemeForest and I'm trying to get the custom post php to check and see if the post is on a category or single post. If it's on category, use <h2> for the title (for ...
0
votes
1answer
91 views

Dynamically adding Captions to images

I have a site where the author has included Amazon Affiliate links. They've done this by adding the URL to product images. I'm wondering if there's a way to add a function that will automatically add ...
0
votes
1answer
69 views

call wp_insert_user in custom class doesnt work

im creating a custom class to manage users in wordpress and chamilo but this is not the point. Class looks like this: class Platform { private $security_key = '..'; private $secret_key; ...
0
votes
1answer
19 views

Retrieve array of attachment IDs attached to a given Post ID

I wonder if there's a function to retreive an array containing the attachment IDs of images that are atatched to a given post. Some function like get_post_arry($pid); The array should be ordered like ...
0
votes
1answer
150 views

Function to list posts from current post's category fails in WP 3.8

I have this function in my child theme's functions.php, whose simple aim is to list a number of posts, only from the category of the current post, but not the current post itself. It was working fine ...
0
votes
1answer
51 views

Optimizing multiple WP_querys into one call?

I have finished building my website and noticed due to the structure it takes 3 seconds to load the data due to each WP_query bouncing between different post types. I was wondering if I put these into ...
0
votes
1answer
58 views

Updating User Meta from Custom Post Field Upon Publish Not Working

I'm trying to get the user_meta to be updated based on the custom post field type. However the information won't transfer if the new post is published by a user through a frontend form. Currently it ...
0
votes
1answer
33 views

How to get tags and categories?

I used the following code to get tags from the post and then simply echo them: $posttags = get_the_tags($post->ID); if ($posttags) { foreach($posttags as $tag) { echo $tag->name . ', ';} ...
0
votes
1answer
252 views

Pass a Select List Value into Functions.php function Tax Query Array

Hoping someone can assist as I am very new to the whole functions.php/wordpress coding side of things but I basically have the following use case that I am trying to achieve through the use of Gravity ...
0
votes
1answer
53 views

wp_list_pages change <ul> of children and anchor of parent

I am getting the list of Pages and Subpages by wp_list_pages(). I want to change the parent <a> and <ul> child. I found a solution here in this WPSE thread. But It only changes the ...
0
votes
1answer
42 views

add slug beside name in Admin Category Checklists

im creating a lot of Categories with the same Name and different slugs, but im having problems identifying which is which in the admin panel, so i came up with the idea of inserting the slug besides ...
0
votes
1answer
41 views

Is there an error in get_the_tag_list()?

I'm using the theme TwentyThriteen1.0 for my WordPress blog. I recognized that the tags in the meta-part of an article are not separated by a comma. I had a look at the function ...
0
votes
1answer
42 views

Admin Panel errors because of functions.php

I'm creating a new theme in WP and I started noticing some errors in the Admin Panel. For example, when I want to update a page adding new content (or a blog post), it redirects to wp-admin/post.php ...
0
votes
1answer
19 views

Pagenav Not appearing on custom Template

I've just finished building a custom page template using the following code. The issue is the pagenav doesn't work - But works on every other page with multiple posts. I want this one to appear if ...
0
votes
1answer
87 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
38 views

How do add_action and WP_Query

I am new to WP, semi-new to PHP and new to OOP. 1) How can the WP function add_action receive another function as its argument? I know this by itself is not possible. I deliberately broke some code ...
0
votes
1answer
83 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
46 views

Could not add 'LoginLogout' link using BAW login logout plugin

I installed and activated the 'BAW login/logout' plugin to bring login or logout link in my screen. but this is not working for me. can some one help me steps I followed: 1) Installed and ...