Please try this:
$args = array(
'category_name' => 'cat1',
'posts_per_page' => 5,
'orderby' => 'rand',
);
$pc = new WP_Query( $args );
where 'rand'
should give you a random order of your posts.
For more info check out the Codex on WP_Query
order parameters here.
Related Posts:
- Find out total number of pages in global query on archive page?
- Post_count only shows the number of results per page
- how to show posts that are missing a meta_value
- What is “main query”? [duplicate]
- WP_Query: query posts by ids from array?
- WP_Query and polylang issue
- pre_get_posts with get_posts
- Is it true $wpdb->get_results is faster than WP_Query in most cases?
- Why does pagination always break when used on any form of a home page?
- Changing a theme’s search function to only show results from woocommerce?
- JSON: schedule creation of json file
- Finding the next 5 posts
- post thumb nail
- Filter by title content and meta key at the same time
- Get all remaining posts after a particular post id
- wp_query with multiple custom fields
- Removing posts from the returned wp_query. Cannot use object of type WP_Query as array
- So strange result of wp_query and have_posts
- How to detect if a function has been fired on any page so scripts/styles can be loaded conditionally
- Minimising number of queries on a page when using Advanced Custom Fields
- $wpdb insert is not work
- WP_Query Ignoring `post_type` parameter
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Improve wp query perfomance on large db
- If two first numbers exist in wp_meta_query value
- How to get the WC_Product Object when using a WP_Query in WooCommerce
- How to query for posts without a post_format
- get_posts – find out if querystring was crap and fallback is used
- Custom Search Result Page displaying only 1 result.
- How to query a custom post type with a taxonomy filter but display post type archive page?
- How to display 7 most recent days of posts?
- WP_Query Variable inside Array
- Function get_queried_object() return NULL in custom taxonomy
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- Search pages that are a child of the current page
- Change query_posts to WP_Query in page but does not work
- The pagination on index.php doesn’t work on a first page
- Include tags in WP_Query
- Modify WP Query post__in before have_posts()
- WordPress search posts by author name with autocomplete
- WordPress multisite – fallback on subsites to main site on 404 and dealing with switch_to_blog function
- Count author posts in certain category
- WP Query using tax_query & meta_query
- Taxonomy Query Relation field not behaving correctly?
- How to control a common terms list from one place?
- Exclude Category filter from Portfolio section
- Search form not working with custom query?
- How to output topics and replies in bbpress as table?
- Is there something wrong w/ this code?
- how to access query string in wordpress?
- Query Vars Not Set in Main Query
- How to get all post except particular category without breaking the paging
- How do I rewrite this loop as a new WP_Query style-loop?
- ACF Query Structure
- Order post type by sum of two custom fields
- exclude product with available tag
- Order WP_Query results by meta key value in custom query
- Need help understanding this WP Query [closed]
- Ordering posts by custom field and grouped by month
- How to get main menu only with wp_nav_menu
- relation OR instead of AND – Filtered term ID’s in loop
- How to get specific string in explode array?
- filter posts by meta key with pagination
- Ajax (jquery) wp_query pagination returns -1
- Query to get result by Title or Meta along with tax_query parameter
- Oxygen Repeater Advanced Query
- Why are my wp_query args being ignored if post_type = CPT
- Use dedicated functions
- Woocommerce Get Orders By Meta Value
- Pagination not working on archive.php template?
- Save large WP_Query to transient === false
- How to show specify category template for both parent and child category
- WordPress Query optimaization for slow query
- WordPress – just refresh blog archive by new query
- how to move a page from one drop down menu to another drop down menu
- WP_Term_Query->get_terms() very slow query for WordPress filter
- How to pass a php variable to js within a template?
- Meta query doesn’t remove placeholder escape before query
- Multiple values in WP_Query : category__and
- Get all wp_users sort by metakey
- How to use wp_query in different column in single loop
- Paginated Post List on Front Page
- Query custom meta value – post view and date meta
- Show subscriber id in loop
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query – show posts where meta value and user_email match
- WP_Query causing links to not work
- Website goes slow down after importing long database
- Orderby Date and Category
- Pagination for custom query throws 404 errors on last pages [duplicate]
- Order posts by custom column using pre_get_posts
- How to Query Updated Post in WordPress
- wordpress nested loop
- Need help setting up a search form for wordpress [duplicate]
- Including ‘cat’ => $cat breaks meta_query
- problem in query_vars parameters
- Limit Tags display and ad Drop Down Menu
- Query posts only shows 1
- First post outside of loop, homepage only?
- Can I use WP_Query to find a post with a particular menu_order?