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:
- What does setup_postdata ($post ) do?
- get_posts – get all posts by author id
- get_post random and order by not working
- get_posts with meta_compare=’LIKE’ not working
- Sort “get_pages” by menu order not ordering
- Get the exact SQL query that get_posts() generated
- Show the First Post from Each of 3 Different Post Types on a Web Page?
- get_posts inside cron
- get_posts returning empty array
- Problem with get_posts, tax_query and counting the number of posts
- custom post type upcoming post and past post
- How to query custom post type by term?
- Check If posts exist in custom post type category, outside of loop
- data returned from get_post($postId) have different keys than wp-json/wp/v2/posts/{postId}
- How to limit get_posts()?
- meta_query date and time comparisons
- Quickest way to get last or oldest post date – WP Query
- What’s the difference between “get_posts” and “wp_get_recent_posts” when used with “setup_postdata”?
- How to generate a list of posts published on current day?
- Get latest posts from multiple categories
- Get_Posts, only if in both categories
- Posts not showing in correct Alphabetical or ID order when using get_posts / orderby but only on production server
- Filter the content from a post globally immediately after is fetched from the database
- Secondary Query Is Breaking Main Query
- Combine query_posts() and get_posts() into single query
- If clauses in get_posts query
- var_dump and print_r cause white screen
- Are there sub-systems in WordPress that would employ data structures beyond CPT that a `get_posts` won’t be able to catch?
- Shortcode for display posts on home page show only one post
- WordPress count child posts of each parent custom post type and use in json array for google maps jquery plugin
- How can I display a single post link, based on title sample and change monthly?
- Display all post titles of current post type
- get_posts() doesn’t consider user permissions
- Stuck in Order by more then one
- How to update all posts but the current one (post__not_in not working?)
- Multiple (two) category postings on the same page.
- ‘exclude’ argument is not working with get_posts for a custom post type
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Only showing the_date and the_excerpt for first entry in get_posts
- 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
- Iterate over get_post_meta() result
- Unique Problem with the php date and get_posts
- Get posts by language in Polylang plugin
- Auto-change Post Status on First Page Load
- 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
- 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?
- 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
- 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