Add Filter not working with get_posts

According with WordPress documentation, the post_where filter will not affect to the query generated by the get_posts() function. See also the default usage of get_posts() where you can see the argument suppress_filters set to true by deafult. In order to run post_where filter in the query generated by get_posts() function you have to set suppress_filters … Read more

Filter a pluggable function

As noted in @Milo’s comment, a function being “Pluggable” is entirely separate from it being filterable. A Pluggable function can be overridden wholesale, because of the if ( function_exists() ) conditional in which it’s wrapped. A Plugin is filterable if its output is parsed through an apply_filters() call. Since you only want to change a … Read more

Regarding post text filtering

The usual way to show the post content, within the loop, is to use: the_content(); that will echo the output, not return it like get_the_content(). But since you want to assign it to the $text variable, you use: $text = get_the_content(”); but then the the_content output filter is not applied. That’s the reason why you … Read more

How to filter bbPress replies (content)?

The solution found: add_filter(‘bbp_get_topic_content’, ‘custommm_functiooonn’); add_filter(‘bbp_get_reply_content’, ‘custommm_functiooonn’); function custommm_functiooonn($content){ return ‘hiiiiiiii’.$content; }

Change the template when the user is not logged in using page_template filter (it does not work)

Your code doesn’t really do any “user logged in” check, and you aren’t using a couple of the globals you import. function restrict_access_to_unlogged_users($template) { if (!is_user_logged_in()) { $template = get_stylesheet_directory() . ‘/need-login.php’; } return $template; } add_filter( ‘page_template’, ‘restrict_access_to_unlogged_users’, 20 ); And you could do this more globally with template_include. function restrict_access_to_unlogged_users($template) { if (!is_user_logged_in()) … Read more

term_link filter gives less atributes

You need to add the the fourth parameter, $accepted_args, to add_filter() to access the second and third parameters in your callback function. Only the first parameter ($url) is passed by default. add_filter( ‘term_link’, ‘authorsongsurl’, 10, 3 ); The 3 in the end tells the filter to provide all the three parameters to your function.

run shortcode in excerpt of single custom post type

You just forgot to return the excerpt for the other post types. Try for example: function do_my_shortcode_in_excerpt( $excerpt ) { if ( ‘services’ == get_post_type() ) $excerpt = do_shortcode( wp_trim_words( get_the_content(), 55 ) ); return $excerpt; } add_filter( ‘get_the_excerpt’, ‘do_my_shortcode_in_excerpt’ );