What to use instead of the content_save_pre filter?

What Adam Brown’s site says is that the hook no longer appears in 3.8. I greped a 3.9 and found: bash-4.2# grep -Rni ‘content_save_pre’ * wp-includes/kses.php:1327: * The wp_filter_post_kses() function is added to the ‘content_save_pre’, wp-includes/kses.php:1344: add_filter(‘content_save_pre’, ‘wp_filter_post_kses’); wp-includes/kses.php:1370: remove_filter(‘content_save_pre’, ‘wp_filter_post_kses’); wp-includes/default-filters.php:89:foreach ( array( ‘content_save_pre’, ‘excerpt_save_pre’, ‘comment_save_pre’, ‘pre_comment_content’ ) as $filter ) { Interestingly the … Read more

How to change Woocommerce breadcrumbs content?

That is due to the fact, that your filter woocommerce_breadcrumb doesn’t even exist. This filter here works and pulls out all the elements, that are currently in the breadcrumb (as an array): add_filter( ‘woocommerce_get_breadcrumb’, ‘change_breadcrumb’ ); function change_breadcrumb( $crumbs ) { var_dump( $crumbs ); return $crumbs; } And this filter pulls out the main term … Read more

How to add attribute to output with wp_video_shortcode add_filter

I get Undefined variable: for $video, $post_id and $library and the video’s in the page are blank. Replace: add_filter( ‘wp_video_shortcode’, ‘my_video_shortcode’, 10, 2 ); with: add_filter( ‘wp_video_shortcode’, ‘my_video_shortcode’, 10, 5 ); to access all five input arguments in your filter’s callback. ps: my_ is such a common prefix, that I would consider something more unique. … Read more

Add wrapper to only youtube videos via embed_oembed_html filter function

$url will contain the full URL to the embed source. E.g.: https://www.youtube.com/watch?v=_UmOY6ek_Y4, so you have to search within $url to see if the provider’s name appears: add_filter( ’embed_oembed_html’, ‘wpse_embed_oembed_html’, 99, 4 ); function wpse_embed_oembed_html( $cache, $url, $attr, $post_ID ) { $classes = array(); // Add these classes to all embeds. $classes_all = array( ‘responsive-container’, ); … Read more

How to use the_excerpt in a filter hook?

use the filter get_the_excerpt. Look at line no. 250 here, they are using the_excerpt internally on the function get_the_excerpt(), and in this function on line no. 272, they’re applying the filter get_the_excerpt on the actual excerpt. Hence, add_filter(‘get_the_excerpt’, ‘exc’); function exc($param) { return “Whew !”.$param; } is the way to go if you want to … Read more

How to make post and comment count unclickable with dashboard_glance_items hook

The dashboard_glance_items filter is only useful for modifying the extra elements. The posts/comments data elements have already been displayed. Here are three ideas: Method #1 – Use the dashboard_glance_items filter: You can use the following filter setup, to remove the posts/pages/comments elements from the output of wp_dashboard_right_now(). The trick is simple, foul WordPress to think … Read more

Overriding wp_get_archives() apply_filters()

A WordPress filter is a function that takes in a string, array, or object, does something to it, and returns that filtered string, array, or object. So what you want to do is turn “WHERE post_type=”post” AND post_status=”publish”” into “WHERE post_type=”post” OR post_type=”events” AND post_status=”publish””. That is fairly straightforward. From the looks of things, the … Read more