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

wordpress get_post_meta give only first value

I made one custome post in that there is one custom field call _as_roomname. I create total 5 custom post and I want to retrive all it's name but I get only first value. function postlogo(){ global ...
1
vote
1answer
231 views

Remove class that has been added by parent theme

My parent theme generates the following class in body: style-cupcake. I don't want that. The best way to get rid of this is by adding my own functions in a functions.php file in my child theme, right? ...
0
votes
1answer
575 views

Post visibility option to theme front-end for author to select?

Is it possible to present author with an option to select visibility of a post (public, private, password) on theme front-end post adding without messing with Wordpress core? Any suggestions are ...
1
vote
1answer
466 views

Setting Up Scheduled Tasks (For Scripts to Run)

I am going to make a script that requires a scheduled run time. What is the best way to do this in Wordpress? Or maybe this can be done through some PHP method? I'm having a hard time finding even a ...
3
votes
1answer
546 views

Different wp_mail_from and wp_mail_from_name for specific situations

I'm wondering how to create differents wp_mail_from and wp_mail_from_name for specific actions that use the built-in mail system in Wordpress. For example, when a new comment comes, notify the user ...
0
votes
2answers
212 views

Wp admin - Set default value to 999 in comments

When you are at the comments menu in wp-admin you only see 20 comments at the time, so if you want to delete alla comments you can ONLY mark the 20 comments you see on current page. It dosent mark ...
0
votes
1answer
188 views

Archive.php, and post_is_in_descendant_category

I've got a small issue with my archive.php. I was trying to set up an If statement that displays a certain category and sub categories with a different layout & sidebar based on my theme options. ...
3
votes
3answers
3k views

Logout redirect to current page - function

I'm looking for a function that can redirect users when they logout to the current page. I'm looking for a code I can use in functions.php?
0
votes
2answers
68 views

Adding code to the function file

I would like to move my large php functions out of the index or template files and into the function.php file. Would it be something like this? function grab_code(???) { ??? .= '<div>some ...
0
votes
1answer
238 views

Single dash converted to double dash

As the title says, if a single dash is used with a space between each side eg. 'Die Hard - Action Film' is written in to a WordPress post, once published it comes out as 'Die Hard -- Action Film'. If ...
1
vote
1answer
99 views

comments_number display outside specified span

I want to display the number of comments a particular post has, so i thought i'd use comments_number, however when i use this the comment number gets printed outside of the span it's supposed to be ...
0
votes
1answer
169 views

List direct children of page

I am currently using the following function to list the children of a page, however the function recursively finds children of the children and I only want to list the direct children of ...
0
votes
1answer
137 views

Conditional Content Display

I"m trying to replace the string "Something Nice will show up here" in the block of codes below with WordPress loop but it doesn't seem to be working. I'd like when Link1 is clicked on, let the post ...
1
vote
1answer
38 views

problem with has_post_thumpnail in foreach loop

I have a code that display the post if has_post_thumpnail the problem is it shows all the posts wheather it has thumpnail or not <?php global $post; $args = array( 'numberposts' => 5 ); ...
4
votes
1answer
197 views

function_exists call in function.php

In the function.php file of the twentyeleven the setup function checks to see whether it exists before running it: if (!function_exists('twentyelevent_setup')): function twentyelevent_setup() { ... ...
0
votes
1answer
708 views

WooCommerce Tabs [closed]

In my theme, I have the WooCommerce plugin installed and would like to rename the "Catalog" tab, located under the WooCommerce > Settings submenu page. Am I able to do this from my functions.php ...
1
vote
2answers
441 views

Image rotation fails to regenerate custom sized thumbnail

I'm using custom image dimensions in functions.php like this: add_image_size( 'custom-size-thumbnail', 120, 120, true ); I uploaded some pictures with wrong orientation, so I used "edit" options to ...
4
votes
3answers
5k views

How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?

The current result is "PHP Fatal error: Call to undefined function wp_get_current_user()" which makes sense, but doesn't help. I need to use $current_user. Here is the code I'm currently using: ...
0
votes
1answer
116 views

Perform function on publish AND save (not just save)

I am using this function to auto-set a post title based on a couple of custom fields: function set_event_title( $data , $postarr ) { if($data['post_type'] == 'event') { $getdate = ...
0
votes
1answer
392 views

Saving multiple Metabox contents

I'm putting together a fairly simple Custom Page for a friend on their WordPress site, but I'm having some real difficulties getting the contents of the Metaboxes to save correctly. WordPress doesn't ...
0
votes
1answer
761 views

add sidebar area to header of child theme

How can I add some extra sidebar locations for widgets in a child theme. The difficulty I'm having is because the parent theme uses some pretty gnarly setup to define the current sidebars. I would ...
1
vote
2answers
51 views

2 Loops, Only Displaying 1 Loop in Both Loops

I have 2 loops, movie trailers and gaming trailers but gaming trailers is displaying under both Movie Trailers and Gaming Trailer. Each loop displays the post tagged with either Movie Trailer or ...
-1
votes
1answer
81 views

Integrating CSS Into a WP Function Call [closed]

Below is a code I use to display post views. It is integrated with an options panel which allows users to choose whether to display it. I would like to integrate the div class .postviews directly ...
3
votes
5answers
3k views

Show Video in Excerpt

So I recently figured out how to change my blog page to display excerpts by changing the <?php the_content(); ?> to <?php the_excerpt(); ?> in my index.php file. I am using a custom child ...
1
vote
1answer
1k views

When tax_query used, results disappear (0 =1 produced)

I'm trying to perform a dynamic query that uses a dynamically passed taxonomy and post_type, and displays results accordingly — A user makes a selection from 3 drop-downs on a form, each have a ...
1
vote
1answer
44 views

Modifying Custom Post Type after registration (will it affect content?)

I have a CPT (defined in functions.php) that I have set to as non-hierarchical. A lot of content has already been uploaded into the database. If I change the definition to 'hierarchical' => true, ...
1
vote
1answer
257 views

echo or print_r in an admin function

I'm currently working my first plugin (to deal with my CPT) and am at the process of saving the values of a meta box. I wish to add an underscore (_) to the meta key so that it is hidden on the ...
0
votes
1answer
131 views

the_post_thumbnail issues

I am trying to make the thumbnail for each post display on the homepage of a site for a client; although the thumbnails do display, they're not being displayed inside of a specified "thumbnail" div ...
2
votes
1answer
632 views

How can one utilize a variable as a callback function name for add_settings_field

I'm trying to cut down on the amount of code that is in my theme options function. I'm adding my settings like so: add_settings_field($k,$v,$callback,$the_options,$the_group,$args); This works for ...
0
votes
2answers
393 views

Show last 5 posts from specific category

I'm trying to show the last 5 posts from a specific category, which will be linked to a function so i can insert the shortcode in a Wordpress page. The code i have is as below, it does everything i ...
0
votes
1answer
71 views

Function Reference for custom link in Admin Menu Management Page

What is the function reference for the text within the URL field in the Admin Menu page? I have a PHP function that is utilizing the_content function reference to look for specific file paths and ...
2
votes
2answers
234 views

javaScript in <head> section of WP API

How do I place the following javaScript in the <head> section of the Wordpress Widgets API menu screen? <script type="text/javascript"> jQuery(window).load(function() { ...
0
votes
2answers
189 views

Using Output from one Function and calling it into another

I'm trying to get my head around a fairly simple concept in PHP but I'm pretty green. I have a function.. function pa_insertPage($atts, $content = null) { // Default output if no pageid given ...
0
votes
1answer
437 views

Custom Function for SEO by Yoast plugin

We use a very customized version of WordPress for some of our index/root site pages where we use a custom meta box for custom permalinks. What we are looking for is a custom function that basically ...
0
votes
1answer
123 views

Generate daily archive whenever any post type is added

We have an issue with our date archive in WordPress, where our daily archive (example address www.xxx.com/2013/01/09) is only generated when a post from the default post type is added. Any day where a ...
0
votes
1answer
105 views

Enqueueing scripts selectively & activation where needed

If I enqueue my scripts selectively, for instance I have a slider I only want to load on homepage, which is activated in main-js, e.g: wp_enqueue_script( 'main-js' ); if ( is_front_page() ) { ...
0
votes
1answer
216 views

template_redirect action only firing if logged in

add_action('template_redirect', 'add_header_redirect', 0, 0); function add_header_redirect(){ if( is_page(array(8, 'testimonials', 'Testimonials')) ){ $default_testimonial = get_permalink( ...
0
votes
1answer
2k views

Shortcodes, output buffering, and WordPress functions

I have a couple of long forms which I want to output as shortcodes. Shortcode API indicates that If the shortcode produces a lot of HTML then ob_start can be used to capture output and convert ...
0
votes
1answer
27 views

Functions Error: Impacting Galleries

The function below controls an option inside an options panel. What it does is choose the number of posts being displayed in a particular archive (to_count archives, to_count_home, to_count search ...
1
vote
3answers
180 views

How to break down importing of feeds

I am attempting to update a large array of feeds into WordPress, using fetch_feeds. As can be expected, when going over 50 feeds the server is starting to time out. I would still like to update the ...
0
votes
2answers
119 views

Is there a way to create a “copy post” link?

Much like the "edit" link when viewing a post, is here a "copy post" function I can include with my theme?
1
vote
0answers
90 views

next_/previous_post_link() `in_same_category` appears to fail when true

I'm using the Modernize theme's custom Portfolio type page. In the single-portfolio.php template, I call next_ and previous_post_link(), which correctly display links when in_same_category is set to ...
0
votes
1answer
455 views

Some problems calling a function into sprintf() inside functions.php template file [closed]

I am new in PHP and WordPress and I am personalizing an existent template and I have the following problem. In the function.php file of the template I have the following function: function ...
0
votes
1answer
644 views

How to hide a plugin metabox for non admins when a user adds a new post

I've been able to disable all the meta boxes for non admin in their backend but I'm having problems with Facebook AWD All in one which creates a widget seen by all the users when they create new ...
0
votes
2answers
217 views

How to add a class and title attribute to the link generated by next/previous post

The following code <?php previous_post('%', '&#60;', 'no'); ?> <?php next_post('%', '&#62; ', 'no'); ?> returns these links, as it should <a ...
0
votes
1answer
584 views

define css class in functions.php

In my theme I use theme options to set colors to categories (heading colors, dividers colors etc etc) The way I do it is defining variables which holds a color hexa like so: $category1_color = ...
0
votes
2answers
874 views

Featured Image keeps cropping

I've spent hours trying to figure this out and its driving me mad. I'm not great with php code so I'm not sure if I'm doing this the best way anyway... It should be simple - I have built a custom ...
0
votes
1answer
43 views

Function in functions.php by url

I want to use wordpress content in external mobile app. I need an URL address to get content from function located in functions.php for example: function test() { return 'it works'; } What I ...
0
votes
1answer
333 views

Display a list of users with avatar filterable with alphabets

I'm trying to create a page which should display a list of users with the role "Author" only and exclude all other default and custom roles. I also want them to be filterable by alphabets, so if I ...
1
vote
1answer
653 views

Merging PHP download script into `functions.php`

I run a large mixtape download site on WordPress. I'm currently developing a new theme and I'd like to include as much site functionality into the theme's functions.php. For serving the downloads, I ...