Home › Forums › Support › Conditional code in hook This topic has 10 replies, 4 voices, and was last updated 7 years ago by Leo. Viewing 11 posts - 1 through 11 (of 11 total) Author Posts September 11, 2017 at 11:30 pm #383640 Aaron I’ve just started trying to write php and am trying to enter a shortcode after content for one category. Here’s what I have: <?php if ( is_category( 'hearing' ) ) : ?> <?php echo do_shortcode( ' [elementor-template id=β701β] ' ); ?> <?php endif; ?> But I cannot get it working. Any idea what I’m doing wrong? September 11, 2017 at 11:41 pm #383648 TomLead Developer Lead Developer Hi there, Are you wanting it to show up after the single post content, or on the category archive page? September 11, 2017 at 11:45 pm #383649 Aaron Hi Tom. Single posts only. Thanks for the quick response. September 11, 2017 at 11:52 pm #383652 TomLead Developer Lead Developer Try this instead: <?php if ( in_category( 'hearing' ) ) : ?> <?php echo do_shortcode( '[elementor-template id="701"]' ); ?> <?php endif; ?> September 11, 2017 at 11:57 pm #383655 Aaron That’s working now. But it’s also showing up on the archive page for that category. September 12, 2017 at 12:28 am #383672 Aaron Got it. Had to add && is_single(). Phew. I really wish conditional statements were easier. Thanks, Tom. September 12, 2017 at 9:49 am #384021 TomLead Developer Lead Developer Glad I could help π October 23, 2017 at 4:57 pm #408753 Mikel Mandon Hi Aaron or Tom, Could you please post the whole code with the && is_single() ammendement? Thanks ! October 23, 2017 at 10:00 pm #408838 LeoStaff Customer Support This should be it: <?php if ( in_category( 'hearing' ) && is_single() ) : ?> <?php echo do_shortcode( '[elementor-template id="701"]' ); ?> <?php endif; ?> October 24, 2017 at 1:56 am #408929 Mikel Mandon Hi thanks for the swift response π —-EDITED and opened a new topic—– Thanks for assistance Mikel October 24, 2017 at 8:00 am #409179 LeoStaff Customer Support Can you open a new topic for your questions? Thanks! Author Posts Viewing 11 posts - 1 through 11 (of 11 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In