Home › Forums › Support › has_category() This topic has 3 replies, 2 voices, and was last updated 6 years, 4 months ago by Leo. Viewing 4 posts - 1 through 4 (of 4 total) Author Posts December 7, 2019 at 3:07 pm #1097357 Jeffrey Hello, I’m trying to add a certain code above my <h1> if the post has a certain category, but I can’t get it to work for some reason. Can anyone help me out? if ( has_category( ‘cm1’ ) ) { add_action( ‘generate_before_content’, ‘test’ ); function test() { echo do_shortcode( ‘<p>testsss</p>’ ); } } December 7, 2019 at 4:41 pm #1097405 LeoStaff Customer Support Hi there, What if you add the if statement inside the function? December 7, 2019 at 8:00 pm #1097492 Jeffrey YES! That worked!Thank you so much! December 8, 2019 at 8:56 am #1097902 LeoStaff Customer Support No problem 🙂 Author Posts Viewing 4 posts - 1 through 4 (of 4 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In