H2 exclude Related Posts on a given post page when defined in Child Theme
-
What a great plug-in! Thank you so much!
I only have one question: I added the code to my function.php of my Child Theme and that works perfectly. However, there is one post, where I do not want to show the “Related Posts” section. How would I do that? Thanks!
add_filter( 'the_content', 'add_related_posts_after_post_content' ); function add_related_posts_after_post_content( $content ) { //check if it's a single post page. if ( is_single() ) { // check if we're inside the main loop if ( in_the_loop() && is_main_query() ) { // add your own attributes here (between the brackets [ ... ]) $shortcode = '[related_posts_by_tax posts_per_page="4" related_posts_by_tax title="Related Articles"]'; // add the shortcode after the content $content = $content . $shortcode; } } return $content; }
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘H2 exclude Related Posts on a given post page when defined in Child Theme’ is closed to new replies.