Hi there,
I had a similar request to this previously. Here’s a code snippet that allows you to remove the reading time from certain Posts based on their Post ID.
add_action( 'the_post', 'remove_reading_time_by_id' );
function remove_reading_time_by_id( $post_object ) {
$post_ids = array(
'53',
'10',
);
global $reading_time_wp;
if ( in_array( $post_object->ID, $post_ids ) ) {
remove_filter( 'the_content', array( $reading_time_wp, 'rt_add_reading_time_before_content') );
} else {
add_filter( 'the_content', array( $reading_time_wp, 'rt_add_reading_time_before_content') );
}
}
@yingling017
Hello Jason,
I enjoy the simplicity and design of your plugin, it works really well. I was looking for a solution similar to the one above, I just need the reading time to NOT display on a certain Blog category. Is there a way to exclude a category so that the reading time will show on all other posts except the chosen category. This would save me having to teach the client about using shortcodes and have him use it every time he wants to post. Any help is appreciated.
Thank you,
Lucas Rodriguez
Hi Lucas,
You could modify the function above to check which category the current post is remove the filter if it’s a certain category.