I am trying to remove the shortcode from a specific post type, in this case link. I used this code on my functions.php but it removes the shortcode from the_content for every post type.

<?php
function remove_shortcodes( $content )
{
    return strip_shortcodes( $content );
}
add_filter( 'the_content', 'remove_shortcodes' );

is it possible to modify this so it only remove the shortcode from “Link” post type?

thanks

2 Answers
2

You would need to use WordPress Conditional Tags to query if this page is the custom post type you are wanting to target and then if it is remove shortcode.

Untested but you can try this:

    function remove_shortcodes( $content ) {

        if ( get_post_type() == 'post-type-name' ) {
            return strip_shortcodes( $content );
        }
        else 
            return $content;
    }

add_filter( 'the_content', 'remove_shortcodes' );

Leave a Reply

Your email address will not be published. Required fields are marked *