Do you want to strip shortcode from your homepage / index but not from single or archives posts? It’s easy with our code snippet. All you have to do is to copy the snippet to your functions.php file.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
function remove_shortcode_from_index($content) { if ( is_home() ) { $content = strip_shortcodes( $content ); } return $content; } add_filter('the_content', 'remove_shortcode_from_index');
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: Best WordPress Page Builders (Compared).
hi i am using the Append Comment plugin to add a contact form to the end of every post(using shortcode for contact form). I added your code but it is still appearing on my home page. any ideas?