WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] using single.php to filter normal and custom post types (2 posts)

  1. pirazo
    Member
    Posted 3 years ago #

    Hello,

    PHP Newbie trying to learn, Looking for some syntax help please:

    I am looking to use single.php to segregate standard posts to one template file and an array of other custom post types to other template files, could someone please help me with making this following code work if I am close, or please point me in the direction of how to make this code work?

    <?php
    query_posts( array( 'post_type' => array('artistgallery', '123') ) )
    if ( 'post_type' => array('artistgallery', '123') {
    include(TEMPLATEPATH . '/single-artist.php');
    } else {
    include(TEMPLATEPATH . '/single-all.php');
    }
    ?>

    It was based on this:
    In the recent past I successfully filtered by category to different template files using:

    <?php
    if ( have_posts() ) { the_post(); rewind_posts(); }
    if ( in_category( array( '5355', '5392', '5393') )) {
    include(TEMPLATEPATH . '/single-video.php');
    } else if ( in_category('82')){
    include(TEMPLATEPATH . '/single-video-vod.php');
    } else {
    include(TEMPLATEPATH . '/single-news.php');
    }
    ?>
  2. pirazo
    Member
    Posted 3 years ago #

    Solved it with:
    http://codex.wordpress.org/Custom_Post_Types#Single_template

    But if anyone want to correct my php, please... :)

Topic Closed

This topic has been closed to new replies.

About this Topic