I have installed the Custom Post Type UI plugin. After activation of this plugin I have created a custom post type called portfolio. Now I want to use this on the portfolio page in the front-end. How do I fetch all post that are of custom post type portfolio?

3

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 Reply

Your email address will not be published. Required fields are marked *