Snippet: Add default content to posts in a specific category

Add following snippet to “functions.php”


add_filter( 'default_content', 'wpds_default_products_content' );
function wpds_default_products_content( $content ) {

    $category_id = MY_CATEGORY_ID;

    if( isset( $_REQUEST['category_id'][0] )
    && $category_id == $_REQUEST['category_id'][0] )
        return "<div>default content</div>";

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>