You can use the following line of code in your category.php file for Random posts.
<ul>
<?php $posts = get_posts('orderby=rand&numberposts=5');
foreach($posts as $post) { ?>
<li><a href="https://wordpress.stackexchange.com/questions/169519/<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php } ?>
</ul>
</li>
Related Posts:
- Create a category list page
- How do I use the same post slug for different Categories?
- How to display only 3 main categories, separated by commas, since they are marked in the post?
- Default WP Gallery – show only galleries of a certain category
- How to tax query X number of posts related by tag first, then by category if not enough in tag-related
- Woocommerce product categories order [closed]
- How do I create a way for users to assign categories to a post from the frontend?
- Exclude sub category posts from category display
- How to hide a specific category posts in my monthly archive?
- Give specific category its own permalink structure
- Create terms when registering taxonomy?
- Automated adding of one tag to all the posts in a category
- How to set up sub-categories for author pages?
- Add category to custom post type automatically, using category slug
- How do I edit pre_get_post for the category the user is currently in?
- Assign different category colours to different categories in the main menu
- wp_list_categories, Add class to all list items with children
- Display Only One Category
- Display only one result from “get_the_category_list”
- Using separator with wp_list_categories
- Connecting WordPress gallery to custom categories (taxonomy)
- Assign an icon to a category post
- How to mass-insert categories?
- Multi-site or categories?
- Custom Category/Subcategory structure
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Remove ‘rel’ attributes from the_category() output
- Default category link for a custom category is a broken link
- View the latest created categories
- If statement within PHP echo
- category hierarchy level as a body class – parent cat =1, child cat=2, grandchild=3
- How to show author name only if the post is in a specific category?
- Are Category or Tag Archive Pages Possible?
- 3 Columns, 3 Categories, One Archive, and Pagination
- How to display only posts assigned to a particular, isolated, subcategory
- How to Exclude post from a category
- Hiding a Categories content on just the Homepage ‘Posts’?
- How to change a post category when the ACF datepicker Field is today
- Multiple Loops on category.php with pagination on last loop
- Two separate portfolio pages [closed]
- woocommerce related products by specific categories [closed]
- Child categories doesn’t echo if it doesn’t contain at least a post
- About title on a page
- custom page for custom Taxonomy
- Why get_category() function is not working not working when embedded in a page?
- Show different title on category page
- How to remove one specific category (uncategorized) from post permalinks
- Combining a meta_query with a category filter
- Theme for subcategories
- How to link a PDF file to a category URL
- Displaying year once in category.php [duplicate]
- Restrict CSS on one page
- Check is category parent with ids from the childs – get_term_children
- Showing posts from 2 categories only on category.php
- Posts not listing out sub category in hierarchy
- Change Default Content when Creating a Post based on Previous Category Choice
- Display category and associated post listings
- list all child categories that apply to current post even if those cats are empty?
- Exclude categories from postquery
- Category pagination not working
- show only sub categories if available?
- How can I set a product’s url to reference the primary category in Woocommerce?
- displaying the last product comment in the woocommerce category
- Show Posts via cat+cat in URL that are in both Categories doesn’t work
- Same category and post base
- exclude certain categories form archive widget
- Private categories in WordPress
- Ignore the Ad on Specific Categories
- How do I make an array to get the category name, dynamically, in an archive template?
- How to prevent WordPress from redirecting single page to prefixed category archive with same name?
- How to edit woocommerce sub-category page
- Hide specific category tag on single post page
- Filtering posts in category by tag URL
- Grab all the posts for particular category
- Get and display category name by category description
- Category pages redirecting to tab on Posts page grid
- How can I add different custom fields for each category in the same post?
- Custom Archive Template for Multiple Categories
- Change the full slug for a specific category?
- Making my category headers smaller
- How to show the posts of some category first, and then the rest? Cant figure out the coding
- Is it possible to query the result of a query?
- ACF plugin categories bug in WordPress 3.9
- List Categories in Custom Order
- How can I hide the category term for posts with none set?
- Allow duplicate permalink slugs for posts in different categories
- Link to a latest news item with correct url
- Post in multiple categories do not include in previous / next post if one category in excluded
- exclude parents from the_terms
- Change rss title of individual feeds?
- Reversing the order of items in a category rss feed?
- Restrict category choice in dropdown menu?
- How can i display in a archive page a number of post i want
- Problems with explode [closed]
- has_category not working correctly
- How to get most recent categories – categories whose most recent posts published
- Category Template – to be editable from the backend?
- Custom permalinks structure
- How to show posts of a specific category
- How to add custom prefix before category base for category page URL?