View wordpress posts by category

Asked

Viewed 429 times

0

Use the code below to display posts from the ID 1, however, instead of using the ID category, I would like to use the Slug EX: cat=news

<?php query_posts('cat=1'); while ( have_posts() ) : the_post(); ?>

1 answer

1


According to the wordpress documentation, I believe this solves your problem:

query_posts( array(
    'category_name'  => 'my-category-slug',
    'posts_per_page' => -1
) );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.