What you want to do, can be achieved by means of the WP_Query
class.
$query = new WP_Query(array(
'post_type' => 'quote2',
'posts_per_page' => 10, // or something else
));
Now you can work with $query
like:
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post;
?>
<h1><?php the_title(); </h1>
<?php the_content();
<?php
}
else {
// No posts...
}
If you just want to get access to the posts, you can do so via $query->posts
.
Related Posts:
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Should I use Transients with W3 Total Cache APC Caching? [closed]
- Add indexing to meta_value in wp_postmeta
- Get posts by menu ID
- Slow SQL_CALC_FOUND_ROWS Query
- What is an efficient way to query based on post_meta?
- WP_Query Performance Issues with meta_query
- Should close $wpdb via $wpdb->close()
- Get the post permalink within the loop but without additional DB query
- Filter WordPress posts by between parameter
- Retrieve featured image (thumbnail) url from multiple posts with one query
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- What’s faster? One big query, or several smaller ones?
- How WordPress attaches its Featured Images with posts?
- Order by custom table and multiplication
- why update and delete query not worked in custom table?
- How to implement a new row_count method in WordPress?
- querying data via $wpdb and get_row
- wp_Qwery works to slow
- Show all data in database table and make it into an interactive table
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- database query with more than a couple meta hangs and doesn’t complete
- How to access custom WordPress database tables
- Is it possible to query from external database? [duplicate]
- WP User Query with Custom Fields and Search Results
- List of ways to access WordPress database?
- Specify strict ‘order by’ in WordPress query
- How to set up hierarchical relationships without using plugins / meta query
- how to get Nearby zipcode
- Does WordPress have something like Drupal’s DB API?
- Using Transients
- Slow Query On Search
- how to write wordpress query for multiple metakeys checking?
- Wpdb->query result show 1 but is not an integer
- Why having more than 10 clauses in WP_Query results in some outputs being dropped?
- Storing an array of objects related to each user
- Retrieve data from wordpress db via input and put those result in dropdown
- WP Query – filtering terms with regex
- WP_Query with page_ids in arguments without a result
- Function to retrieve IDs of posts, cache results, and improve wp_query
- Issue with data array format
- Why last row deleted when refresh page
- Query a database based on form input then output to another page [closed]
- wp query search multi terms
- How to get meta key list efficiently?
- How to get user avatar via WPDB
- How to extend WP_query to a specific table?
- Fix wp_term_relationships slow query in get_posts
- Translating WP query into to SQL query
- update_post_meta performance in a loop woocommerce
- update_post_meta performance in a loop woocommerce
- WP_Term_Query->get_terms() very slow query for WordPress filter
- Separate by Category Post Type
- I removed the “wp_rm_logs” table and am constantly getting this error
- Track write actions to the database
- Include post_status check within $wpdb query
- wpdb get_results() returns only 2 rows
- Website goes slow down after importing long database
- WP_Query always returning the last custom post
- option select form always deleting the sql query
- Optimising amount of calls to custom fields
- 294 Queries on Mainpage of WordPress
- Custom WP_query in Jnews theme returns thousands of posts
- WP_Query by meta key not returning any posts
- SQL query into to WP query
- Merging a complex query with post_rewind and splitting posts into two columns
- Filter wp_query to search post title in function
- Two queries on the same page with pagination
- Best approach to create Hot and Trending sections
- get complex results set according to category structure
- Setup of taxonomy term template pages
- Ignore post by meta value in the main query
- Display posts in 3 days chunk
- WP_Query’s “request” SQL Query
- is_search was called incorrectly
- Empty tax_query array returns an empty array
- Sorting By Custom Posts With Attachments
- Most commented last 24h, week, month, year and all time – posts_where
- Why isn’t my `meta_query` array functioning properly?
- Dynamic User Id
- Multisite pagination issue by multi query archive 404
- Hide elements outside loop based on query
- Modify query posts
- Filter subpages in while loop from WP Query object
- WP Query Order By Multiple Values
- Error: Attempt to read property “ID” on null
- Unrelated post showing in WP_Query
- Custom meta_query order for Elementor based on post meta key [closed]
- wordpress pagination wont render on custom page template even though its right under the loop like the documentation says so
- How to query search only for post titles?
- Shortcode attributes causes 500 error after updating the page
- query_posts based on a meta_key
- Query with two posttypes and two different meta_keys
- Sort by meta key within same day
- Duplicates When using Nested WP_Query
- Show portfolio items in template – how?
- Problem with WordPress 4.0 and $wp_query
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- wp_query loop with compare operator simply not working, why?
- How to get all post_id and meta_value using meta_key in wp_postmeta table