I want to display all posts of a post format (let’s say: aside). In WordPress to display all posts of a certain category, just need to use this URL: mysite.com/category/mycategory. Is there a similar way to display all posts of a post format? Or any other way is also fine for me.
Leave a Reply
You must be logged in to post a comment.
You could use tax_query parameters to get the posts by post_format. For example:
Then you can iterate over the results with get_posts() (or use WP_Query() and a standard a Loop):
WordPress creates archive pages for each post format automatically.
Use the get_post_format_link() method to generate the link to the WordPress archive for each post format (although this method does not work with the “standard” post format).
See The Loop.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
That code above list all of the post on your wordpress site, so to show all post from a category you need the use the
if ( in_category('CategoryNumberHere ')
function to only fetch post from a category. You must also know the number of the category in your WordPress installation.Take a look at the linked page above, it has a full tutorial and layout of how to do such things. The code specific to categories is the second section down.