Articles of filters

get_bookmarks filter not supplying query argument (wp 3.1)

I’m using a filter on the get_bookmarks function. When I use two arguments in my filter function I get the result array and nothing for the second arg (it should be the parsed query). Here’s what I’m mean: function samiconductor_sort_links_by_order( $results, $args ) { echo print_r($args); // nothing function order($a, $b) { $a_order = get_option( […]

How do I add a TinyMCE row that all users can see, instead of just admins?

Currently I have successfully added a row of shortcode buttons to the TinyMCE editor in WordPress. The problem is, only admins can see the row, and I need contributors and editors to see it too. I have checked the Codex for add_action and add_filter and I can’t see any specific arguments to indicate user roles […]

How do I alter the comment form 'allowed tags' text in a plugin?

I’m using the PHP Markdown plugin, and I’d like to modify it so that it adds some text to the bottom of the comment form indicating that Markdown is supported in comments. I’ve been modifying my theme to do this, but the theme is updated quite frequently and I don’t want to create a custom […]

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’ ); function my_editor_content( $content ) { $content = “default content goes here….”; return $content; } My modifications include: add_filter( ‘default_content’, ‘my_editor_content’ ); function my_editor_content( $content […]

problem with implementing widget via the_content()

hey guys, I really need you help with this one. I’m using the subscribe2 Plugin (for email subscriptions). I want to show the signup form as a widget. The plugin author recommends doing it the following way. $content = apply_filters(‘the_content’, ‘<!–subscribe2–>’); $content = remove_filter(‘the_content’, ‘page_route’); echo $content; this works fine, except for the fact that […]

Remove bulk actions based on user role or capabilities

How can I remove the “bulk actions” based on user roles or capabilities. Actually I have this code to do the job, but now I need to exclude the site admin, I need to let the administrator to access the bulk menu add_filter( ‘bulk_actions-‘ . ‘edit-post’, ‘__return_empty_array’ ); add_filter( ‘bulk_actions-‘ . ‘upload’, ‘__return_empty_array’ ); How […]

Custom Post Templates

The Issue: I am looking for custom single post templates, to add or remove individual elements as a function of a normal single post. There are a lot of ways to create custom post templates for single posts within WordPress. Especially post formats are a great chance to use default templates for default cases; however […]

Filter my args by the post 1st letter

I filter my WP_Query by this script: $args = array ( ‘posts_per_page’ => $posts_per_page, ‘post_type’ => $post_type, ‘meta_key’ => ‘post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘showposts’ => 160, ‘order’ => ‘DESC’, ‘paged’ => $paged, ‘tax_query’ => array( array( ‘taxonomy’ => $term->taxonomy, ‘field’ => ‘slug’, ‘terms’ => $term->name))); And I would like to add the filter SUBSTRING(post_title, 1,1) […]

Can I the caption shortcode to set caption to a data attribute, and with the image's alignment intact?

I want to output an image caption in this kind of format: <img class=”alignleft size-medium wp-image-316″ alt=”Image Title” data-caption=”Here lies the image caption” src=”http://example.com/wp-content/uploads/image-400×266.jpg” width=”400″ height=”266″> I got the basic caption code from WP Core and ran it through the add_filter( ‘img_caption_shortcode’, ‘my_magic_caption’); filter, which seems to work fine. My problem is that I can’t […]

How do I pass the value from a foreach loop to an add_filter function?

I’m trying to add multiple filters from inside a foreach loop. Unfortunately I can’t get the code to reference the value properly. How do I pass the value from the loop to the function? The following sets all the filters to null. foreach ( $myarray as $key => $value ) { add_filter( “plugin_filter_$key”, function( $value […]