Add default content to posts in a specific category?

Using the code you posted, the selected category’s ID is available in the $_REQUEST, you can check that ID against your products category in the default_content filter and add content if there’s a match:

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

    // change this to your desired category ID
    $products_category_id = 42;

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

Leave a Comment