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)

2
votes
1answer
14 views

How to display post tags through the functions file

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 ...
2
votes
1answer
391 views

Gravity Forms field entries into wp_query loop

I have a simple function that filters the page content when form (ID 18) is submitted. It simply displays the entry of field (ID 13)... add_action("gform_after_submission_18", "set_post_content", 10, ...
2
votes
1answer
97 views

How can I list random authors from current post category?

The following lists authors of the current category. But I want this to be a list of 6 random authors from current post category. foreach((get_the_category()) as $category) { $postcat= ...
2
votes
1answer
4k 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
87 views

How to get correct URLs in network wide menu (Multisite)?

I'm using this function to switch to my main website's navigation and display it on all sub sites in my multisite network. Ideally the links should have the following format: ...
1
vote
1answer
135 views

How to set the jpg image compression for specific thumbnail sizes?

This question was asked on Set JPEG compression for specific custom image sizes and answered very nicely by Ahmad M I'd of course comment to that thread but I don't have 50 point reputation... The ...
1
vote
1answer
273 views

Function to auto-set a featured image that is already in use

I don't even know where to start with figuring this out.... This function for functions.php grabs the first attached image in a post and sets it as the featured image. The problem is that it will not ...
1
vote
1answer
263 views

Remote upload file to server B

I'm aware this might be some of the hardest coding to do ever, but thought of giving it a try. Im basically trying to detect all (mp3) filetypes uploaded through the Wordpress media upload and send ...
1
vote
1answer
72 views

PHP mixed with some JS code to update Wordpress theme settings

I am working on my first Wordpress Theme but I am facing a little problem in my code. In fact, I have created a little page in the administration to change some settings on my theme and, for example, ...
1
vote
1answer
38 views

Where to add the permalink in this function?

Below is a function that displays the latest 4 approved comments on my homepage, I wrote this almost a year ago, and for the life of me, it's gone completely from my head, All i want to do is add a ...
1
vote
1answer
128 views

Delete pages and Create default pages for all new network sites

I am using the following code to delete some default pages and to also create some default pages for all new sites that are created. It work as is now but that is only because I purposely have a ...
1
vote
1answer
306 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
51 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
32 views

Display post x of y within category

I'm currently using this class in my single blog posts to get a total post count and number my posts (post 89 of 90, etc...) class MY_Post_Numbers { private $count = 0; private $posts = array(); ...
1
vote
1answer
72 views

Wordpress Theme Update Action?

I've done quite a bit of searching. I'm looking for hook/action called after a theme update. I know the initialization one - but a basic update? Cannot seem to find. If one does not exist, how can ...
1
vote
1answer
63 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
78 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
76 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 ...
1
vote
1answer
565 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
93 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
83 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
287 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
64 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
821 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
50 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
220 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
10 views

update_usermeta don't work

When I return in the function $setfound, I become a white screen and when I return $setlink, it works fine. function editsteamlink(){ $setlink = $_POST['steamlink']."/?xml=1"; $setresponse = ...
0
votes
1answer
19 views

is_dynamic_sidebar always returns true while using Jetpack visibility

If I have any widgets in the sidebar, even if the jetpack visibility is set to not show on that page, is_dynamic_sidebar return true. Here's the code in my theme functions file: add_action( 'init', ...
0
votes
1answer
29 views

get_post_meta not working inside a function in functions.php but works outside

function notify_new_posts($post_id) { $keyval = get_post_meta( $post_id); $buyer_wdistance = get_post_meta( $post_id, 'cf_wdrive'); //$buyer_wdistance = $keyval['cf_wdrive'][0]; ...
0
votes
1answer
27 views

Can't get link if there is no post available

I have a function which creates a link for the taxonomy term , with the selection of post_type. function get_custom_term_link( $term, $taxonomy, $post_type ){ $link = get_term_link( $term, ...
0
votes
1answer
46 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
42 views

Creating wordpress user registration form

I am having a form page called Test Form with this form : <div id="container"> <form action="wp-content/themes/max-magazine/TestForm.php" method="post" name="myForm"> User <input ...
0
votes
1answer
39 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
35 views

How to add 'data-caption' inside an anchor tag

bellow is custom gallery code. function custom_gallery_shortcode( $attr = array(), $content = '' ) { $attr['itemtag'] = "li"; $attr['icontag'] = ""; ...
0
votes
1answer
23 views

How to add an anonymous function in wordpress hooks by removing create_function

Currently I have the code below which I would like to replace create_function with some anonymous function. How can this be done? add_action('widgets_init', create_function('', 'return ...
0
votes
1answer
41 views

'Attempt to modify property of non-object' warning

I use the bellow function to disable a plugin update. It works, because I use an old version of this plugin and it does not show me that a newer version exists, but, however, I get a warning on line ...
0
votes
1answer
57 views

Wordpress - thumbnail image from youtube (function and loop)

Hi :D i need show thumbnails from youtube in homepage, i have a code for wordpress in function and the loop but not working thumbnail from youtube. What can be wrong with the code? Function Code: ...
0
votes
1answer
33 views

Call two different function.js depending on page

I'm trying to find how I can call 2 different function.js depending of the page. When on "home", I want to load "function_2.js", and on the other pages of my website the original "function.js". I ...
0
votes
1answer
30 views

Create html from function

I have a simple html structure like this. <div class="ideaPost"> <a href="<?php echo get_permalink($post->ID); ?>"> <div class="ideaPost__Info"> ...
0
votes
1answer
31 views

Dynamically Generate Functions and Hooks

I'm trying to find if it's possible to dynamically generate functions and hooks. All functions do the same thing, and all hooks are essentially the same. Here's an example of a hook/function combo: ...
0
votes
1answer
48 views

How to access global variable $menu inside a class function

am puzzling why can't i access the global variable $menu inside a php class function class adminMenus { public function getWPdefaultmenus(){ global $menu; return $menu; } } using ...
0
votes
1answer
48 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 ...
0
votes
1answer
113 views

Replacing select2 in admin backend for all selects

I originally posted this question as a javascript question here, but think maybe it would be better asked here. I tried adding select2 to all wordpress admin screens. However, since many selects are ...
0
votes
0answers
111 views

User driven content problems

I am trying to build a website that will allow users to post from the front end. I need to be able to have the user enter a title, a category, and tags. For the content of the post, I would ideally ...
0
votes
0answers
103 views

How do I link a button I created in theme customizer to a function?

I created a button in the theme customizer and I want to use it to execute a function? All I can find is using controls to add theme settings such as CSS and text. Although this button is to clear out ...
0
votes
0answers
59 views

Wordpress adding in site URL to header links

A little information: I am developing a one page theme that uses posts as sections on the main page. I have created code that allows users to add a menu item in the post page from a meta box when they ...
0
votes
0answers
233 views

How can I clear the theme mod settings?

Ideally I am looking to add a button to the theme customizer that allows the theme to reset to default settings, although that may be asking for too much in one question so I am wonder if anyone knows ...
0
votes
0answers
144 views

Cant get theme to change footer color through theme customizer

I am having an issue trying to configure the theme I am working on to allow the footer color to be changed. So far all of my other options work so I am geussing it is an issue with the way I am ...
-1
votes
0answers
8 views

wordpress filter function to change a string

I want to change word "one" to always be output as word "two", I want it to change on just the admin level AKA:theme options. I'm currently looking at a str_replace() function to replace the string ...
-1
votes
0answers
24 views

Is there a function like wp_remote_fopen that takes a post/page ID instead of a URI?

We have dev and test environments that are only accessible from the internal company network but our WP installations (only part of the whole domain) are hosted on Amazon Web Services. I have need ...