Forums

How to check if it's not a post type (5 posts)

  1. estevancarlos
    Member
    Posted 1 year ago #

    is_post_type seems to be deprecated and so I need to find a way to check if something is not a post type.

    I thought something like this would work:

    <?php if ( 'project' == post_type_exists() ) { } else { ?>
    <h3>Archives</h3>
    <?php wp_get_archives( 'type=monthly&limit=12' ); ?>
    <?php } ?>

    It does not. Any suggestions?

  2. estevancarlos
    Member
    Posted 1 year ago #

    I tried "get_post_type()" as well and it does not work.

  3. keesiemeijer
    moderator
    Posted 1 year ago #

    Try it with this:

    <?php if ( post_type_exists('project') ) { } else { ?>
    <h3>Archives</h3>
    <?php wp_get_archives( 'type=monthly&limit=12' ); ?>
    <?php } ?>

    http://codex.wordpress.org/Function_Reference/post_type_exists

  4. estevancarlos
    Member
    Posted 1 year ago #

    This seems to almost work the way I want? What I'm trying to do is have certain content show on the 'single' post type and nothing show on the 'projects' post type. It seems to recognize the existence of the 'projects' post type but it acts the same way on any page. I want to hide show content depending on the post type of the page displayed.

  5. estevancarlos
    Member
    Posted 1 year ago #

    Nevermind, this works

    <?php if ( is_singular('projects')) { } else { ?>
    <h3>Archives</h3>
    <?php wp_get_archives( 'type=monthly&limit=12' ); ?>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags