[Resolved] After content

Home Forums Support [Resolved] After content

Home Forums Support After content

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #286246
    Cristina

    Hi!

    I have an image set after content in my posts, using <?php if ( is_single ( ) ) : ?> in the GP Hooks.

    What I want to do now is to set a different image depending the post. I want the image that I already have in every post (just in posts, not in pages), except in the posts of a specific category, where I want to put another image.

    Is it possible to do that?

    #286286
    Leo
    Staff
    Customer Support

    Hi Christina,

    Try something like this:
    <?php if ( is_category( 'Category Name' ) ) : ?>

    Let me know if this works.

    #286358
    Tom
    Lead Developer
    Lead Developer

    To target a post inside a category, you would use the in_category() condition.

    So you could do this:

    <?php if ( in_category( 'Category Name' ) ) { ?>
        Content for your "Category Name" category.
    <?php } elseif ( in_category( 'Another Category' ) ) { ?>
        Content for your "Another Category" category.
    <?php } elseif ( is_single() ) { ?>
        Content for all other single posts.
    <?php } ?>
    #287077
    Cristina

    Thank you very much!! It worked! ๐Ÿ™‚

    #287079
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

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