Site logo

[Resolved] has_category()

Home Forums Support [Resolved] has_category()

Home Forums Support has_category()

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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>’ );
    }
    }

    #1097405
    Leo
    Staff
    Customer Support

    Hi there,

    What if you add the if statement inside the function?

    #1097492
    Jeffrey

    YES! That worked!Thank you so much!

    #1097902
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.