Articles of filters

global function to apply filter to custom field

I have an action hook which works perfectly for the_content. I would like to apply the same hook anytime a handful of custom_fields are requested. The custom fields are 1) myfieldone 2) myfieldart 3) myfieldestion So lets just take one of those – “myfieldone” Is there a way – where anytime “myfieldone” custom field is […]

Check for template part, else filter content

In a plugin which brings its own post type to the table, I wish to handle post_meta by filtering the_content – unless the user has provided their own single-{post-type}.php template. Should I run this within the_content filter? Or elsewhere? if ( file_exists( get_stylesheet_directory() . ‘/single-event.php’ ) ) { include( get_stylesheet_directory() . ‘/single-event.php’ ); } elseif […]

Automatically set default password to all posts in a specific category

Let’s say that we have a category with slug protected_category and some posts in it. Is there a way to force all posts in that category to be password protected using a default password? UPDATE: I found a solution how to set a default password to all posts in a custom post type: add_filter( ‘default_content’, […]

Post Content, Special Characters and Filters

I added a hook to the_content. add_filter(‘the_content’, ‘edit_the_content’); function edit_the_content($content){ return $content; } Pretty simple right? However, when it output $content from within my edit_the_content() callback it seems like WordPress converts some, but not all characters into special characters. Example: it’s = it’s but then an anchor tag, remains untouched and not converted. Is there […]

apply_filters('the_content') – make it ignore shortcodes?

I am using apply_filters(‘the_content) so I can see properly formatted content inside my wp editor in the backend. However, this also renders the shortcode that’s in the content. I want it to ignore the shortcode and apply filtering to the rest of the content, basically the same thing as when making posts. If you view […]

Contact Form 7 filter similar to preprocess_comment

Does the Contact Form 7 plugin have a filter similar to WordPress’s preprocess_comment? I’ll be using this filter to check the body of the message for certain words and call wp_die() to display a message and prevent further processing of the message.

Debugging – trying to add search box to menus

I have already asked a similar question at stackoverflow (, but maybe that was the wrong place? As you can see there I am trying to add a search box in the way I have seen recommended: add_filter(‘wp_nav_menu_items’,’menu_search’); function menu_search($items){ $search = ‘<li class=”search”>’; $search .= ‘<form method=”get” id=”searchform” action=”/”>’; $search .= ‘<input type=”text” class=”field” […]

Using wp_handle_upload() to direct specific path by using $overrides

How do you use wp_handle_upload function and apply_filter together to upload files on a specific path? What is going to be the override? For example: $overrides = array(‘file’ => ‘C:\\uploads\\filename.pdf’,’message’ => ‘File written’); apply_filter(‘wp_handle_upload’,$overrides); or something like that? Or is this the right code? The real question in here is: what $overrides can be used […]

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( ‘woocommerce_myaccount_page_id’ ) ), false ); if ( ‘Shop Menu’ == $args->menu ) { $items .= ‘<li id=”menu-item-login” class=”menu-item menu-item-login”>’ . $link . ‘</li>’; } return $items; } add_filter( ‘wp_nav_menu_items’, ‘rp_add_login_logout_links’, 10, 2 […]

Inserting above the comment template

I want to insert content, just above the comment template.I have tried all the word-press filters and hooks but failed. I want to insert the content above the comment template, I mean above all comments. Thanks EDIT function my_fields() { echo ‘<p>action/p>’; } add_action(‘comment_notes_before’,’my_fields’); Please see the image-I want to insert content in color part […]