• I’m building a portfolio site, and the client has decided he would like his portfolio (custom post type) on the index rather than his blog (plain Jane posts). Switching over the index is easy, but how can I use the loop on a static page other than the index? I tried making a page called “blog” and setting the old index template to it, but the loop passes over the (null) content of the page, rather than the posts. Any advice?

    To cut out this suggestion, it’s not ideal to categorize these posts and show a category. Seems like a bit of unnecessary work to categorize a post just to make it show up.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi Melanie,
    Try query_posts?

    Found this example, and just changed the post type and posts per page to 8:

    //The Query
    <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ?>
    // current page times the amount you want to show per page -chapeau Justin Tadlock
    <?php $offset = ( 8 * $paged ) - 8; ?>
    <?php $args=array(‘paged’=>$paged, 'posts_per_page'=>8, 'post_type'=>'portfolio', 'offset' => $offset); ?>
    <?php query_posts($args); ?>
    
    //The Loop
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    //what you want to display from the query… excerpt images etc..
    
    <?php endwhile;?>

    HTH

    David

    I’m building a portfolio site, and the client has decided he would like his portfolio (custom post type) on the index rather than his blog (plain Jane posts).

    First, some nomenclature clarification (so we’re all on the same page): by “on the index”, do you mean “on the Front page”? I will assume this is what you mean.

    Switching over the index is easy, but how can I use the loop on a static page other than the index? I tried making a page called “blog” and setting the old index template to it, but the loop passes over the (null) content of the page, rather than the posts. Any advice?

    To create a custom template for the Front Page:

    1) Create template file front-page.php, according to your needs
    2) Create a Static Page, either with content or as a place-holder, to which to assign as the Front Page.
    3) In Dashboard -> Settings -> Reading, change “Front Page displays” from “blog posts” to “Static Page”
    4) Assign the Static Page you created in Step 2 as the Front Page.

    To display blog posts somewhere other than the Front Page:

    1) Create a Static Page, as a placeholder, to which to assign the blog posts index.
    2) In Dashboard -> Settings -> Reading, assign the Static Page you created in Step 2 as the Blog Posts Index.

    That should be all you need to do.

    Hi Chip,
    I was reading it more as getting the custom post types into the loop, the OP’s post is a bit confusing, but does mention custom post types!

    To cut out this suggestion, it’s not ideal to categorize these posts and show a category. Seems like a bit of unnecessary work to categorize a post just to make it show up.

    So I think it will require a mix of the two, a template page with a custom loop for the (custom post types only) ‘post_type=portfolio’, then setting this to the home page?

    I’m building a portfolio site, and the client has decided he would like his portfolio (custom post type) on the index

    David ??

    @adeptris: absolutely! ??

    For creating a custom Loop, i.e. for a Custom Post Type, get_posts() [Codex ref] is a great option, and likely the one I would suggest for the OP.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Main loop on page other than index?’ is closed to new replies.