How can I get the default content of WordPress post?

Is there a way where I can get the default output of the_content in WordPress post? Some of the plugin is using add_filter to the content to add their desired result like related post plugins where they add the result at the end of the content of a post. What I want to happen is to get the default formatting functions of WordPress core without any additional filters from other plugins.

Related posts

3 comments

  1. You can use the_content filter itself to get the post object or the content , you can modify it or you can unhook it and again hook it as per your requirement .

    If I have understood your requirement this link will help you, if you need something different please ask me.

  2. Guys thanks for responding to my question I think I got it somehow but need to run more test. What I did was I replicate the process on how the_content() function of WordPress work. Base from my research there are 10 default filters coming from WordPress core you can see on this link: read here

    I just created my own function like the_content() from WordPress and apply the default filters to my own function. Put this code in your functions.php

    if(!function_exists(default_post_content)){
        function default_post_content( $more_link_text = null, $strip_teaser = false) {
            $content = get_the_content( $more_link_text, $strip_teaser );
            $content = apply_filters( 'default_post_content', $content );
            $content = str_replace( ']]>', ']]>', $content );
    
            echo do_shortcode($content);
        }
    
        add_filter( 'default_post_content', array( $wp_embed, 'run_shortcode' ), 8 );
        add_filter( 'default_post_content', array( $wp_embed, 'autoembed'), 8 );
        add_filter ( 'default_post_content', 'wptexturize');
        add_filter ( 'default_post_content', 'convert_smilies');
        add_filter ( 'default_post_content', 'convert_chars');
        add_filter ( 'default_post_content', 'wpautop');
        add_filter ( 'default_post_content', 'shortcode_unautop');
        add_filter ( 'default_post_content', 'prepend_attachment'); 
    }
    

    Then for example in your single page template(single.php) instead of using the usual the_content I can use my function default_post_content();. Now I don’t need to worry about any of the plugins that create additional data to the_content() function.

Comments are closed.