if (is_singular('subjects')) {
echo '<div id="link_count">';
the_content();
echo '</div>'; //end of link_count div
}else{
the_content();
}
If this is just simplified code for the question, but you’re going to have more items in and around the_content, you can just wrap 2 of the if statements around the call for the div and end of the div…
if (is_singular('subjects'))
echo '<div id="link_count">';
the_content(); //and whatever else goes here.
if (is_singular('subjects'))
echo '</div>'; //end of link_count div.
In either case you’ll want to make sure that the CPT is actually “subjects” and not namespaced when it was created or this won’t work. ie you’ll need the right name of the cpt as registered in the if statement.
if you want to add to a functions.php, try this. It’s not tested but should work:
function add_content_link_count( $content ) {
if (is_singular('subjects')) {
$custom_content="<div id="link_count">". $content . '</div>';
} else {
$custom_content = $content;
}
return $custom_content;
}
add_filter( 'the_content', 'add_content_link_count' );