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?
- What does setup_postdata ($post ) do?
- setup_postdata() does not seem to be working?
- Regenerate Slugs From Title of Posts
- get_posts – get all posts by author id
- 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
- WordPress get_posts by category
- Get the ID of the latest post
- get_post random and order by not working
- 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
- get_posts with meta_compare=’LIKE’ not working
- List most recent image uploads, but only for specific custom post type
- How to restore deleted pages/posts?
- Sort “get_pages” by menu order not ordering
- get posts based on meta value of the author
- date_query not returning some posts in date range
- Get the exact SQL query that get_posts() generated
- How do you get posts by meta_query using the JSON API plugin?
- Get all authors with at least one post of ‘custom post type’
- Show the First Post from Each of 3 Different Post Types on a Web Page?
- Why favour the standard WP loop over iterating over (new WP_Query())->get_posts()?
- Query posts ordering by title, but ignore ” and special characters
- get_posts inside cron
- functions.php conditional tag only for custom post type
- Retrieving 3 latest post from each of 5 different custom post types
- get_posts not honoring post_status
- get_posts returning empty array
- get_posts only children from certain parents
- Problem with get_posts, tax_query and counting the number of posts
- custom post type upcoming post and past post
- get_posts cannot grab from specific category
- Filtering custom post type query
- How to get only one category of custom post type?
- post__in not taking my list of IDs
- How to query custom post type by term?
- Check If posts exist in custom post type category, outside of loop
- Getting a custom post type image using ‘get_post_custom’
- data returned from get_post($postId) have different keys than wp-json/wp/v2/posts/{postId}
- How to limit get_posts()?
- Get random custom posts from a custom post type
- meta_query date and time comparisons
- get_posts from post x(offset=>x) to end
- With get_posts(), how can I put a category as a variable
- 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”?
- 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
- Increase the page size of the WordPress REST API
- How to generate a list of posts published on current day?
- Trouble using get_post
- Cache Get_posts
- Get latest posts from multiple categories
- get_posts() returns all posts rather than the ones specified with ‘post_author’ =>
- Query random post from different 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
- get_posts() excluding all children of a specific post/page
- 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
- `get_posts()` ignore my custom post
- 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
- excluding current post from get_posts
- How to query posts to include specific pages of one post type, and all pages of another post type?
- WordPress count child posts of each parent custom post type and use in json array for google maps jquery plugin
- Only retrieve posts where post_excerpt has been filled out
- Can I use numberposts=-1 and offset together when using get_posts()?
- Ordering posts in get_posts
- I don’t arrive to do order_by title when i have a conditionnal year in a request
- How inefficient is it to use a Custom Post for 4-5 sentences & pull all to 1 page?
- How can I display a single post link, based on title sample and change monthly?
- Display all post titles of current post type
- Display content based on a users login
- get_posts() doesn’t consider user permissions
- Meta query: get posts with value in a multidimensional array
- Get posts inside Get terms problem
- Better way to list links with different meta values using same meta key?
- Stuck in Order by more then one
- Query Multiple Custom Posts by Custom Fields
- Ho to add get_relative_date and post_except to this get_latest_post query?
- 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
- How to get the intersection of two terms both from different custom taxonomies
- 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
- post__in select all custom posts and not the selected array of ids
- get_posts() return NULL using a custom plugin and add_submenu_page() with Post Type
- WordPress duplicating posts from single loop
- get_posts() function does not honor correct post type
- remove pagination from a single blog entry