how to localize the number of wordpress post views?

The problem is most probably, that you don’t actually call the filter. WordPress does this not automatically for you. If you want to create a custom filter you have to manually call apply_filters, so that the added filters get executed: function the_views($postID){ $count_key = ‘views’; $count = get_post_meta($postID, $count_key, true); if($count==”){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, … Read more

What is the scope and persistence of add_filter() and remove_filter()?

It is always global. add_filter() and add_action() are just wrapper for the global variable $wp_filter. So it doesn’t matter where the function is called. The same is true for apply_filters(), apply_filters_ref_array(), do_action_ref_array() and do_action(): they work in the global namespace, that’s the reason why the callback handlers (functions or methods) have to be public. A … Read more

Filter and Search

I don’t believe there’s anything automatic for what you’re looking for, no. I built a similar functionality for sorting products with dimensions, but this was all custom as I did not find anything that suited my needs. You’d need to look into pre_get_posts using $_GET requests.

Clean/filter HTML inserted to post content by XML RPC

From the save_post Codex page: save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. So, if you hook into save_post you can run your filter before save: add_action( ‘save_post’, ‘wpse_75871_save_post’ ); function wpse_75871_save_post( $post_id ) { … Read more

How can I display wp_link_pages before a shortcode, if it is used, or display after content?

Do something like this. // your shortcode callback function your_sc_callback($atts,$content) { $content = wp_list_pages(array(‘echo’=>false)).$content; define(‘YOUR_SC_RAN’,true); return $content; } Now, in your theme template after the content prints if (!defined(‘YOUR_SC_RAN’)) { wp_list_pages(); } Or, you could do … function append_list_pages($content) { return $content.wp_list_pages(array(‘echo’=>false)); } add_filter(‘the_content’,’append_list_pages’,100); And your shortcode callback would be … function your_sc_callback($atts,$content) { $content … Read more

Sanitizing a custom query’s clauses

I would suggest to think in this way: if I can not sanitize whole query (as you can not, what does sanitized mean? Is DELETE or DROP malicious or wanted query? Your plugin would have to be able to determinate the intended purpose of each query ant it is unreachable.), you can predict it’s content. … Read more

Filter image and text from post format

I’m pretty sure you’d define the custom post formats in functions.php, then they’d reference their own PHP file which contains the loop you’d need. So for example, Text format would go to post-text.php, Image format post-image.php, etc. You could add your match filters into a function within functions.php, and then call the function from within … Read more