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;?>
Related Posts:
- How do I get posts by multiple post ID’s?
- How to get post content by calling ajax?
- Why get_posts are only showing five posts (retrieved by assigning a category to them?
- Exclude Current Post from Recent Posts Loop
- How to get all children and grandchildren of a hierarchical custom post type?
- Alternative to get_posts() due to multithreading cache crash
- Getting the Intersection of Two Custom Taxonomy Terms for a Custom Post Type?
- How to get current post ID in quick edit callback
- How to restore deleted pages/posts?
- How do you get posts by meta_query using the JSON API plugin?
- Why favour the standard WP loop over iterating over (new WP_Query())->get_posts()?
- Retrieving 3 latest post from each of 5 different custom post types
- get_posts not honoring post_status
- get_posts cannot grab from specific category
- post__in not taking my list of IDs
- Getting a custom post type image using ‘get_post_custom’
- Serialized array, grab specific posts with meta_key/meta_value[0]->is_featured
- How do I combine these 2 queries
- get_posts gives different result than wpdb->get_results
- Trouble using get_post
- Cache Get_posts
- `get_posts()` ignore my custom post
- I don’t arrive to do order_by title when i have a conditionnal year in a request
- Display content based on a users login
- Meta query: get posts with value in a multidimensional array
- Better way to list links with different meta values using same meta key?
- Query Multiple Custom Posts by Custom Fields
- How to get the intersection of two terms both from different custom taxonomies
- How to get the post content from a category on my homepage
- get_posts() not working in functions.php
- Query Problem in getting top viewed posts
- get_posts not working as expected
- Get all pages and posts with get_pages() or get_posts()
- Exclude post format from get_posts
- Get only used meta_values
- Custom query for custom post_type
- Iterate over get_post_meta() result
- Unique Problem with the php date and get_posts
- get the post_date of ID
- Get posts by language in Polylang plugin
- Auto-change Post Status on First Page Load
- Not able to get random post
- Displaying multiple post types on home page
- Conflict between wp_list_pages and get_posts – list pages not displaying
- SQL query generated by WP_Query is not the same what request echoes
- Calling setup_postdata() causes “Call to undefined function get_userdata()” error?
- custom hierarchical taxonomy and custom post type list contains surplus posts
- Cron task firing but function not working
- wp json api – get posts by category
- Custom Post type Query post is not working
- Get all posts with a certain meta key, except for one with specific title
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Modified home page query does not yield expected results
- Query custom posts of logged in user only
- Add ul to its children with get_posts
- get_posts by id not working
- Select objects from get_posts()
- Display a random customposttype2 excerpt in single-custompostype1.php that shares same taxonomy
- Using post title as term in query, only working with single word titles
- Single random post in homepage
- Get posts in archive page
- How to query custom post types with multiple keys?
- Paging result of get_posts in function
- Get_post_custom not fetching value from array wordpress
- get_posts wont produce a list of custom type from a given category [duplicate]
- Modify default Related Posts Code to Custom Post Type
- get_posts returning empty array
- Update all WordPress posts’s title and content then display them in a table
- get_post Question
- Query a custom taxonomy in a function to create an csv file
- get the_content by ID and save the result to one array
- week days sorting based on starting day
- Zero posts returned with get_posts() on edit.php, but posts are returned on post.php
- Get post from Category by Priority
- How can you use a page for a custom post type?
- Better way to query posts?
- Using get_posts, I need to use a combination of OR & AND relations
- Get number of posts in each category since last visit
- Running get_posts within get_posts to get children of children
- WordPress get all post with like in terms [duplicate]
- Get_posts not returning any posts when used with switch_to_blog
- Get images by category
- How To Use get_posts & get_the_post_thumbnail Outside The Loop
- one get_posts to return a number of custom posts for each meta value
- How to show only 1 post from a specific category on the front-page
- Query for draft or scheduled post
- Custom Post Type children and grand-children in one list
- get_posts() and ‘posts_per_page’ arg
- get_pages not returning any results or error when get_posts works
- Show posts in a list separated by day
- How do I display the index position of a post from a custom post type?
- Function to get content by ID
- Display post’s description and caption
- get posts based on category and post meta
- How to show only text from post in WordPress
- Install wordpress and replace database (from previous site)
- How to I add count of custom posts listed in a post as a prefix to its title
- Create a hierarchical list of posts that’s grouped and nested by category
- How can I show a field ID in Elementor with Request Parameter
- get_posts() function does not honor correct post type