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
4answers
1k 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
1k 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
1k 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
2answers
317 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
442 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
736 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
254 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
571 views

How can I tell if I'm on a login page?

There are functions for is_home(), is_blog() is_single() etc... What's the best way to tell if I'm on a page that is requesting that I login? I guess that would just be the wp-login.php page.
1
vote
2answers
2k views

Default or Preset Content for Custom Post Types

I am trying to modify the code for default content to display based on post type, but so far I have been unsuccesful. The base code is: add_filter( 'default_content', 'my_editor_content' ); ...
1
vote
5answers
272 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
176 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
4answers
4k views

Why isn't is_page working when I put it in the functions.php file?

I have page called "Apple", the page's ID id 2533. In page.php file I have line: echo $bannerimg And this function in functions.php: if ( is_page( '2533' ) ) { // also tested with ...
1
vote
1answer
500 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
372 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
194 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
564 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
51 views

Copy and delete a directory with WordPress functions

I have successfully used copy_dir() to copy a directory to a new location. How can I delete a directory using WordPress functions?
0
votes
1answer
42 views

Simple/basic use of get_current_screen

I would like to load a stylesheet on only 3 admin pages: post.php?post=7&action=edit post.php?post=10&action=edit post.php?post=18&action=edit I was trying with admin_enqueue_script ...
0
votes
1answer
47 views

Display WordPress Search

I am trying to display the current WordPress search term on single.php, index.php, and category.php...basically when someone searches for something I'd like WordPress to remember what the last search ...
0
votes
2answers
84 views

Pagination custom query

I am trying to make a custom page template that shows the most viewed posts. I can return posts but I am having trouble figuring out how to paginate it. Here is what I have: $args = array('orderby' ...
0
votes
2answers
160 views

How to hook into the quick edit action?

I found this solution to automatically assign parent terms when a child term is selected, which is working fine for the save_post hook: add_action('save_post', 'assign_parent_terms'); function ...
0
votes
1answer
136 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
0answers
73 views

automatically adding submenu items

Here's the solution that @bainternet has posted here: Add child pages automatically to nav menu /** * auto_child_page_menu * * class to add top level page menu items all child pages on the fly * ...
0
votes
1answer
64 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
1answer
308 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
77 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
3answers
1k views

How can I loop into two different DIVS without repeating the DIVs

I am having a little trouble trying to figure out how I can accomplish this: I have a container with two colums in it, a right and a left column. Each column will have 3 posts with a short excerpt ...
0
votes
1answer
134 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
72 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
208 views

display most popular tags in two columns

I have a section in my sidebar where I'd like to display my most popular tags in two columns. I found this post from WPSnipp that details how to narrow your list down to only the most popular, however ...
0
votes
1answer
142 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
35 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
3k 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
303 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
164 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
2answers
342 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
132 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
170 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 ...
0
votes
1answer
585 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 ...
0
votes
2answers
324 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
171 views

Adding a user's ID behind the <a> tag ref link address

Good day, everyone: I want to make wordpress to add the user's id number behind the ref's link string, so that, for example <div class="toolsbutton"> <a ...
0
votes
2answers
294 views

Remove Menu Page Giving Error

I have a snippet of code I've written in the functions.php file which is simply to remove menu pages if the user cannot activate plugins. It works as intended; however it is showing a PHP error in ...
0
votes
1answer
145 views

How to add an admin function only to posts, not pages?

I'm having a problem with adding an excerpt counter to the excerpt field. It may be a conflict with another plugin, but basically it screws with other jquery if the excerpt field doesn't exist (e.g.: ...
0
votes
2answers
153 views

Using locate-template & shortcodes doesn't appear to work

For organisation, I'm trying to split up the functions.php file into separate files. In particular the functions for shortcodes in a separate file, with the shortcodes being defined in functions.php. ...
0
votes
1answer
78 views

How to shorten code with function?

Now on the front page, in the part with post excerptions I have such a code: <div class="wiadPodtyt"> <ul> <?php $piwa = get_posts( array( 'posts_per_page' => 2, 'cat' ...
0
votes
1answer
673 views

Generate featured images old posts

I am looking for a way to generate featured image per post based on the first image in the post for old posts without a set featured image. I'm switching from handmade thumbnails to auto generated ...
0
votes
1answer
391 views

Using email_exists() wp function in an ajax request

I'm requesting the wordpress function if (email_exists($email)) { ... } from a file (email_check.php) via ajax. Using this function is causing a server error though. The origin (from an input text ...
0
votes
1answer
609 views

Displaying Saved Meta Box Data in Drop Down with selected()

I have a custom meta-box for certain custom post types, and one of those fields in the meta-box is a drop down. I am providing the field correctly, saving the information, and even calling it ...
0
votes
1answer
3k views

How to call a function only once (global variable scope)

I have been trying to work out the most effecient way to use functions in WordPress. I have a big slow function big_slow_function() that ideally is only run once. But I need to use the boolean that ...