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
2answers
891 views

Removing the default sidebar from admin panel

I would like to remove the default sidebar from my template, it is not needed and I do not want to confuse the user that will be using the admin panel. I have created my own sidebars that are a bit ...
5
votes
2answers
62 views

Remove Actions/Filters added via Anonymous Functions

That's a freaking bad practice I must say. Spent last two hours finding a solution to remove actions and filters added via Anonymous functions. This is the code used on a Parent Theme, and I need ...
4
votes
2answers
632 views

Build a content and excerpt grid loop with paging and options for # of posts

What I'd like to do: on index.php, a loop that shows a selectable number of full posts using the_content and then below that shows a selectable number (the number of posts can be hardcoded in the ...
3
votes
1answer
2k views

How to export comments in WordPress?

I want to export my comments to Excel, PDF or Word. The format really doesn't matter, I just want them exported. I tried the Export Comments plugin, the standard one, but couldn't get it to work, I ...
2
votes
2answers
471 views

Auto close (hide) custom metabox / set default state

I am using the WordPress function add_meta_box() to add my own custom metabox. So how can I auto close/hide on page open ? Currently, I just add a CSS class closed to metabox's <div> element ...
2
votes
2answers
947 views

Unable to get_the_content(); of a post in Wordpress via AJAX

I'm trying to ajaxify my Wordpress theme and I use the method described here and I'm now trying get_the_content of post via functions.php. Using jQuery, when I do alert(data) I get the 'title' echo ...
2
votes
1answer
441 views

When to check if a function exists

I've just started developing a WP plugin, and i've been reading some code from other plugins as a way to get started. I've seen a couple of plugins that wrap all or some of their functions in the ...
2
votes
1answer
690 views

If function exists, and array is met, echo function?

I have a function like the following: <?php echo my_custom_function( array( 'category_url'=>'My Special Category' ) ); ?> It pulls data from the "My Special Category" and displays it. I ...
2
votes
2answers
2k views

Can't access WordPress functions in file called via Ajax?

I am trying to reload the fresh posts using jQuery. As far as I know, I can't reload the contents of a div inside the page so I reload a file into that div. The problem is that my loaded file gives ...
1
vote
1answer
58 views

Saving Plugin settings to the database

I'm not a complete novice with php or wordpress but am wanting to approach this problem the most efficient way so believe asking here will help. I've got a plugin that randomly generates a quote - ...
1
vote
1answer
51 views

Common functionality between my own plugins

I read that when creating new post types, creating a settings page, and creating a new taxonomy, you should create a plugin. So I have done that. But I have functionality, which could be generalized, ...
1
vote
1answer
411 views

Extending auth_cookie_expiration based on user role

I'm trying to extend the lifespan of the authentication cookie, but only for administrators. My code in functions.php is: add_filter( 'auth_cookie_expiration', 'change_admin_cookie_logout' ); ...
1
vote
2answers
81 views

Dynamically Register Sidebars For Each Top Level Page

I have a small website that wants a different sidebar for each page containing blocks of text, blocks of images, and blocks of links, etc. What I'm trying to do is register a sidebar for each top ...
1
vote
2answers
332 views

gform_after_submission content appears immediately after <body>, not in post body

I have the following function that successfully uses form fields (IDs 13 and 18) from a Gravity Form (ID 18) as parameters within wp_query. This displays a list of posts with specific taxonomy terms ...
1
vote
1answer
82 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? ...
1
vote
1answer
303 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 ...
1
vote
0answers
364 views

jQuery Plugin to use Wordpress functions in AJAX request

I'm using Chained Selects jQuery Plugin to create multiple chained selection fields. I'm using the remote version of the plugin to build the related options by means of AJAX request from a separate ...
1
vote
2answers
885 views

can you set a default value to a custom field

I'm looking to set a default value to a specific custom field, in case the client doesn't add into the custom field it already has a specific number associated with it. one step deeper, I'd like it ...
1
vote
4answers
589 views

change a post status when users update posts?

Is there an efficient way to change a post status from 'published' to 'draft' when a user of a certain type tries to update their posts. I tried something along these lines function ...
1
vote
2answers
887 views

function to include is_home, is_archive, is_category, is_author etc in one function?

I'd like a way to target only blog-area pages for specific formatting. So far, <?php if (is_home() || is_single() || is_category() || is_archive() ) { ?> works okay, but is there a way to ...
1
vote
1answer
765 views

Add a Post Thumbnail to an RSS Feed with custom size

I have two different blogs on the same domain and my goal is to get the 3 latest posts from blog1 to show on the home page of blog2. Everything goes well following these instructions: ...
1
vote
3answers
802 views

the_post_thumbnail fallback using hooks

I am using this big theme that is almost entirely relying on widgets and sliders. Now I trying to avoid looking for post_thumbnail output code in all the included files in order to achieve fallback ...
1
vote
2answers
204 views

Short_title character problem

I am using this code to shorting the title: function short_title( $after = '', $length ) { $mytitle = get_the_title(); if( strlen( $mytitle ) > $length ) { $mytitle = substr( ...
1
vote
2answers
291 views

How to Append to the_excerpt() Function

I have the following snippet of code: <?php>$more = '.....';?> <p class="extra"><?php the_excerpt(); ?></p> What I am trying to do is append the value of $more to ...
1
vote
1answer
645 views

How to display most viewed post in my sidebar?

Hey i wanted to display the 5 most popular post by view count in my sidebar, but i don't want to use a plugin, i want the php function so that i can edit it manually such as adding thumbnails next to ...
1
vote
1answer
1k views

What is the correct MIME type for PSD (Photoshop)

I am trying to create an upload area (frontend) for word press users on a site. I've got a lot of types opened up through some function calls, but unable to correctly get PSD support. I'm seeing a lot ...
1
vote
1answer
226 views

exclude category from WordPress Form function

I have this function and I need to somehow exclude a category number 14 from my submission form. Is there any way to do it inside this function? function retrieve_cat_data($byid = false){ ...
1
vote
1answer
2k views

Edit the_content function

I want to edit the default function the_content(). I know i can add_filter('the_content', 'with_my_function') but im having trouble outputting the old content with mine. Heres an example of what im ...
1
vote
5answers
239 views

Problems with removing admin bar

I am trying to remove the admin bar from a theme front end of a theme. I found the following code block: add_filter( 'show_admin_bar', '__return_false' ); remove_action( 'personal_options', ...
1
vote
1answer
163 views

Display the number of user comments

I would like to display, on the author/user/contributor page, the number of comments the user has posted, and the number of comments he has received on his posts. Is it possible? Thank you !
1
vote
1answer
481 views

Can't filter wp_get_attachment_link

Can't figure out why this won't work: function my_get_attachment_link($html){ $postid = get_the_ID(); $html = str_replace('<a','<a rel="shadowbox['.$postid.']"',$html); return ...
1
vote
1answer
2k views

Targeting specific menu with wp_nav_menu_items

Hey! I have added a wp_loginout() to my header using a snippet in my functions.php: add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2); function add_login_logout_link($items, $args) ...
1
vote
2answers
360 views

write in functions.php

i just want this code to be added in my functions.php, so that it will directly display after my post ends currently i am adding this code to my single.php, but i want to add this is in functions.php, ...
1
vote
1answer
193 views

Function returns different value when called from 'save_post' than when called on page load

The "word_count" function below returns different values depending on where its called from. Why? add_action('save_post', 'my_custom_save', 10, 2); function myPlugin($post) { global $rockScore; ...
1
vote
1answer
538 views

How often is functions.php loaded?

Trying to get my head round functions.php and am wondering how often it is loaded?
0
votes
1answer
30 views

relation OR instead of AND - Filtered term ID's in loop

Question not related anymore.. First I tought about the relation OR/ AND for results, but I believe I should work with 'operator' => 'NOT IN'. I would like to query the results that meet multiple ...
0
votes
0answers
36 views

Create thumbnail on PDF upload with Gravity Forms

I'm working with some great code that was provided recently to create an image thumbnail from a PDF upload, and I'm now trying to implement this in the functions file so that it can be applied to any ...
0
votes
1answer
68 views

How to call a plugin function in footer.php

I want to call this http://wordpress.org/plugins/easy-media-gallery/ easy media gallery plugin in footer.php or recommend me any image gallery plugin like its in the footer of this website ...
0
votes
1answer
30 views

While Using Static Pages, How Can I Get /blog into the URL of Each Post?

I have Wordpress installed on the root of my website. It is using a static homepage and posts page. As it stands, each post will look like this example.com/blogpostname. I don't want to use category ...
0
votes
1answer
102 views

custom post type upcoming post and past post

I want to retrieve inside my archive-CPT.php most recent upcoming post ( post with status of future) and past post (oldest published post). This is how my archive-CPT.php is looking like: <?php ...
0
votes
1answer
42 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
39 views

Possible to register multiple custom taxonomies in one function?

I'm registering 7 custom taxonomies in my functions.php. Since each function uses the same labels and arguments and is attached to the same Custom Post Type, I'm wondering if it's possible to register ...
0
votes
1answer
33 views

date function not correctly returning date

This code is being used to generate the date of a post in wordpress: <span class="the_date">Posted: <?php echo get_the_time('F d, Y'); ?></span> However it is not resutning the ...
0
votes
2answers
869 views

How do I get the current edit page ID in the admin?

Most solutions I found are for front-end use. This is for a plugin, so the all activity is in the back-end. How do I get the page ID that's being currently use(edited) in the admin? Note I'm out of ...
0
votes
1answer
231 views

Random Featured Image Based on Category

I am looking to extend the below code to select a random featured image based on a specific category. The below works but uses an overall list of images to pull from vs a list of images based on ...
0
votes
2answers
48 views

Change a sidebar name?

I'm using a child theme created from a twenty-twelve theme, the theme packs a number of sidebars one which is called "Main Sidebar". Is it possible to change it's name to something else?
0
votes
1answer
175 views

Call to undefined add_action() in theme's functions.php

Once done validating a form with ajax, I use php within my functions.php to actually send the form. <?php $name = $_POST['fname']; $lname = $_POST['lname']; $subject_line = $_POST['subject']; ...
0
votes
2answers
230 views

How to change a certain text or term of WordPress into a custom into the whole site?

In my WordPess site for client, I used Posts as Products, Comments as Customer Review, Subscribers as Registered Customers and so on. For client's I used Admin Menu Editor to edit the wp-admin menu ...
0
votes
1answer
93 views

WP_Cron doesn't do the job: Multisite stats

I already found out how to get the amount of networkwide posts in WPMS. Until now the function was called by a user who opens the website. So it was rebuild every 24 hours. I don't want to let a ...
0
votes
1answer
100 views

Why do I get undefined function export_wp()?

I'm trying to create a function in functions.php or a plugin to generate an export via a cronjob, similar to how Chris_O did this question. However it seems that I can't call export_wp(), I keep ...