Query for custom post type? [closed]

query_posts( array( 'post_type' => array('post', 'portfolio') ) );

which shows both normal posts and posts inside portfolio type

or

query_posts('post_type=portfolio');

for only portfolio.

Use as normal WP Query – read the Codex: http://codex.wordpress.org/Function_Reference/query_posts#Usage and http://codex.wordpress.org/Function_Reference/query_posts#Post_.26_Page_Parameters

<?php 
    query_posts(array( 
        'post_type' => 'portfolio',
        'showposts' => 10 
    ) );  
?>
<?php while (have_posts()) : the_post(); ?>
        <h2><a href="https://wordpress.stackexchange.com/questions/6417/<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
        <p><?php echo get_the_excerpt(); ?></p>
<?php endwhile;?>

Leave a Comment