A standard WordPress install doesn’t keep track of visits to pages/posts. So without a plugin there’s no way to know which posts/pages are visited most often. As to finding random posts that’s as simple as:
$args = array(
'post_type' => array( 'post', 'page', 'my-custom-post-type' )
'orderby' => 'rand',
);
$query = new WP_Query ($args);
Related Posts:
- How do I reorder (pop and push) items from WP_Query?
- Reverse chronology of post listing
- Ajax load more button in Recent posts widget
- WP_Query orderby not working with meta_value_num and menu_order
- How can I sort posts by the date and a custom meta field?
- How to order posts by meta_value and title
- how to get post order by post id wp_query?
- Display current post position in Elementor Posts widget
- How to show multiple posts thumbnail, title and date in widget
- query posts with selected post ids first
- WP_Query sort by meta_value_num or date
- Random order of the 5 most popular posts
- My custom query is displaying random posts in random order
- Get query result according to merged array
- Order by ‘s’ using WP_Query()
- Image inside the content is replaced with featured image from my older post
- How to limit the number of posts that WP_Query gets?
- Get current menu_order
- Get current post id in functions.php
- Random sort within an already sorted query
- WP_Query offset argument does not work
- what types of order can I pass to get_posts() via orderby?
- Search by Hyphen
- Exclude drafts in all() view of edit.php
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- WordPress Number of Posts Not Changing With posts_per_page
- Pagination not working on Custom Page Template
- Exclude posts with specific meta_value while sorting by a separate meta_value
- Problem ordering posts with numbers for titles numerically E.g. 1, 10, 100
- Display custom post types by date field
- Display the latest posts, published in the last hour, with WP_Query
- Fetch posts from current week (Sunday to Saturday)
- Converting multiple loops into one single loop with pagination
- How would I get 1 latest post from a query for 5 posts?
- Display posts from #6 to #20 on archive page
- How to start with post number x?
- Exclude posts with empty post_content in wp_query
- Exclude posts from featuring
- Lazy Load using WP_Query pagination
- Only display a certain number of posts, dependent on how many posts there are available in a query
- AJAX filter posts by year
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- Yearly archive page for future year
- I want to get title name of post, but i didn’t get by this code. Any suggestion?
- Custom WP_Query with complex ‘post_status’ argument
- is there a way to show the the post title after the image?
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Blog post per page setting conflicting with custom WP_Query?
- Ajaxify This Code
- Pausing and Resuming WP_Query results
- Select only post id and meta value with WP_Query
- How to : pagination in 3 different custom loops on the same page
- Query Posts by Custom Field
- how can i change WP main archives loop to sort by name or title
- While loop articles – if statement order
- How do I extract just the post ID of the first item in whatever WP_Query returns?
- Show post content and title in diferent divs using WP_Query using a loop
- Loop doesn’t exclude the specified category in home page
- How to get posts published on the latest date?
- Page and post loop same template
- Show metabox value last post excerpt, title and link
- get_previous_post() while accounting for sticky posts
- WordPress Loop: How to display recent posts in multiple divs
- Random posts that always include a particular post?
- Conflict array_splice on loop and query in widget
- WP_Query of Category Not Showing First Post
- Change content off every sixth element
- WordPress Query – Display 5 posts (same post type), each from a given tag
- While loop in functions.php outputting the_title() of each post on frontpage
- Custom Fields – How to get the list of a specific active widget each time it rendered
- Show posts from two specific category in WP_Query
- How to create loop of posts except post ID defined via ACF field
- Displaying all posts from other sites on the network on one site
- Multisite how to display merged posts from two sites and sort by latest date?
- a WordPress connected to 2 database
- WP_Query that targets all categories
- Fill the exclude array() in get_posts()
- Double loop output
- Displaying a specific sub-category’s posts from wp_query
- Custom layout manager for posts
- Display WordPress Post By Date
- How to make post button to a random post
- Get results from the main wp_query
- Post List Widget with custom posts and editing the Read More Link
- How can I display a specific number of post in a category via a url
- Where is object, property or label in the database that controls the order of the posts being displayed?
- Query category-specific, paginated posts and allow viewer to change sort order
- Pagination for custom query won’t let me back on page 1
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to use in_category?
- WP_Query based on a custom field result
- How to get single post by one author?
- List posts related to category on a div [closed]
- Wp_query WooCommerce products
- posts_per_page – Repeats only first posts ‘post__in’ array
- How to create a cumulative posts and members count
- query_posts different amount of posts per page [duplicate]
- Add custom PHP (no-SQL) filter to WP_query
- How do I get content of custom post type through post ID
- Filters do not work when there are multiple (one works)