If you want to get posts from category using the slug in WordPress? Replace your category parameter with category_name.
1 2 3 4 5 6 7 8 9 10 | <?php global $post; $args = array( 'numberposts' => 10, 'category_name' => 'cat-slug' ); $posts = get_posts( $args ); foreach( $posts as $post ): setup_postdata($post); ?> <divs with the_title() the_excerpt() etc ></div> <?php endforeach; ?> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.