WordPress.org

Ready to get started?Download WordPress

Forums

Conditional Statement for a Custom Post Type Category (5 posts)

  1. Chris
    Member
    Posted 1 year ago #

    Hey all
    I have been trying to work out a conditional statement for a custom post type category. I want to do a "if" the post type category is X, then show Y and if it is not X, then show Z. I currently and trying the following but it isn't working and I don't know what to do. Any help would be awesome!

    Thanks

    <?php if (array ('post_type' => 'linecard', 'is_category' => '5')):?>
    <?php echo '<a href="' . get_permalink($pageChild->ID) . '">'. get_the_post_thumbnail($pageChild->ID).'</a>' ?>
     <?php else :?>
    <?php echo '<a href="' . get_permalink($pageChild->ID) . '">'. get_the_post_thumbnail($pageChild->ID).'</a>' ?>
     <?php endif;?>
  2. Frumph
    Member
    Posted 1 year ago #

    Is this for your archive.php file?

  3. Chris
    Member
    Posted 1 year ago #

    No, I am using it in a page. I would be styling the thumbnail differently in one of the instances. Thanks!

  4. Andrew Bartel
    Member
    Posted 1 year ago #

    Hi Chris,

    Are you using this in a template? Are you within a standard loop?

  5. Frumph
    Member
    Posted 1 year ago #

    global $post;
    if (($post->post_type == 'myposttype') && is _category('slug-name-of-cat')) { }

Topic Closed

This topic has been closed to new replies.

About this Topic