Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer

up vote 7 down vote accepted
query_posts( array( 'post_type' => array('post', 'portfolio') ) );

witch shows both normal posts and posts inside 'portfolio'

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="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
        <p><?php echo get_the_excerpt(); ?></p>
<?php endwhile;?>
share|improve this answer
can u please give me complete code mean how to call title or content – shalu Jan 6 '11 at 10:35
Thanks for reply .i know this but how to implement. – shalu Jan 6 '11 at 10:36
Updated my post now.. :) – Martin Aleksander Jan 6 '11 at 10:44
Thanks alot – shalu Jan 6 '11 at 10:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.