an action hook when a post reaches a certain number of views

Use the action from update_post_meta(): do_action( “updated_{$meta_type}_meta”, // example: updated_post_meta $meta_id, $object_id, // post ID $meta_key, // ‘view’ $_meta_value // view count ); Something like this should work (not tested): add_action( ‘update_post_meta’, ‘badge_check’, 10, 4 ); function badge_check( $meta_id, $post_id, $key, $value ) { if ( ‘views’ !== $key or 1000 > $value ) return; … Read more

How does wordpress add ‘style’ attribute to element

WordPress of course does nothing so it might be a plugin do this, or a custom theme function. How does this happen? The plugin may use the_content filter to find all “” element and inject content. Or it can be a visualize text editor with JavaScript code that modify content itself without applying a filter. … Read more

What are the steps + prerequisites for using an add_filter?

I like to think of add_filter as a way for you to adjust a variable. It can be used anywhere you see an apply_filters in the code. Typically, you return a variable value instead of echoing it out. Your example would be better written like so: function remove_footer_admin () { return ‘Fueled by <a href=”http://www.wordpress.org” … Read more

Gallery stripped from excerpt of post

Your theme most likely uses the_excerpt() function. This function takes the post content and removes all formatting and shortcodes (including the shortcode), and truncates it to a certain amount of characters. What you could try is removing this function, and replacing it with the_content(), which still respects the <!– more –> tag in posts, but … Read more

automatic title through filter

I don’t understand why your “titles” are in the post body content, but you should not be echoing content from that filter. You should be creating and returning a string. function auto_dummy_titles($content) { if (strpos($content,'<h1>’) === false) { $content=”<h1>PLEASE ADD H1 TITLE TO THE PAGE</h1>”.$content; } return $content; } add_filter( ‘the_content’, ‘auto_dummy_titles’); The function does … Read more

How to disable a wp filter in a certain admin panel page

This should work, I guess: function my_init() { global $pagenow; if ( is_admin() && $pagenow != ‘edit-tags.php’ ) { add_filter( ‘image_send_to_editor’, ‘html5_insert_image’, 10, 9 ); } } add_action(‘init’, ‘my_init’); There is also get_current_screen function, which will be perfect here, but… You can use it after admin_init hook, and your image_send_to_editor is called earlier, I guess.

alternative to the_content filter

In functions.php: function myExcerpt($text) { $text = str_replace(‘]]>’, ‘]]&gt;’, $text); $text = strip_tags($text); $excerpt_length = 50; // max number of words $words = explode(‘ ‘, $text, $excerpt_length + 1); array_pop($words); array_push($words, ‘-N’); $text = implode(‘ ‘, $words); return $text; } In your loops: echo myExcerpt ( get_the_content() );