• hello, first sorry for my bad english.

    I’m trying to make a page get all posts from select custom post types, like ‘movies’, ‘books’, ‘others’
    I really don’t know how to do it, totally noob at php :/
    here’s my custom page template:

    <?php
    /**
     * Template Name: Home Page
     */
    get_header(); ?>
    <section id="content" class="clearfix">
    <?php
    $args = array(
    	'post_type' => array( 'movie', 'book', 'other' )
    );
    $query = new WP_Query( $args );
    ?>
    <?php while(have_posts()) : the_post(); ?>
                <div id="content" class="site-content" role="main">
    				<div class="item-list">
    					<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark">
    					<?php the_post_thumbnail('models-thumb'); ?></a>
    					<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a>
    				</div>
                </div><!-- #content -->
    <?php endwhile; ?>
    </section>
    <!-- #content -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    i dont know what should i do, thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter magrao

    (@magrao)

    nevermind i found the solution, a bit simple…

    <?php
    /**
     * Template Name: Test
     */
    get_header(); ?>
    <section id="content" class="clearfix">
    <?php if ( have_posts() ) : ?>
    <div id="post-listing" class="clearfix">
    <?php while ( have_posts() ) : the_post(); ?>
    <?php endwhile; ?>
    <?php endif; wp_reset_postdata(); ?>
    
    <?php $args = array(
        'post_type' => array('model', 'stage' ),
    );
    query_posts( $args );?>
     <?php while (have_posts()) : the_post(); ?>
        <article id="post-<?php the_ID(); ?>" class="post columns four item">
          [content]
        </article>
        <?php endwhile; ?>
    </section>
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Need help with multiple Post Types on a page.’ is closed to new replies.