Site logo

Archived topic

Conditional Hook

3 replies · Started by Dan on July 11, 2019

Viewing posts 1–4 of 4

HI
Any idea why this is not working? (located in functions.php)

if ( is_single() ){
add_action( 'generate_after_main_content','ds_recent_articles' ); 
function ds_recent_articles() {  
   
echo do_shortcode('[wp_show_posts id="422"]');

 }

 }

Without the condition it works, but then displays the posts on all pages.

Thanks
Dan

Thanks Leo.
Moving the conditional into the function fixed the issue.
This site specifically doesn't have GP premium, so a hook inside functions.php had to do.

Thanks again for your great support, much appreciated.

Dan

No problem :)

This archived topic is closed to new replies.