0

Is there a way to make a page show a list of post excerpts ONLY of certain specified categories without editing Wordpress' php files? I'm helping someone who won't be able to edit it later and make it work past Wordpress updates and want to make sure it's easy. Plugins would be preferred. Haven't found anything out there so far.

1

2 Answers 2

0

You can use WP_Query to lists posts with excerpt from specific category. Here is sample code:

<?php 
$args = array(
    'posts_per_page'   => -1,
    'cat'              => 7,
    'orderby'          => 'post_date',
    'order'            => 'DESC',
    'post_type'        => 'post',
    'post_status'      => array('publish', 'draft', 'pending' ),
    'author'           => 1,
); 

$postslist = get_posts( $args );
foreach ( $postslist as $post ) :
  setup_postdata( $post ); ?> 
    <div>
        <?php the_date(); ?>
        <?php the_title(); ?>   
        <?php the_excerpt(); ?>
    </div>
<?php
endforeach; 
wp_reset_postdata();
?>

You can modify it according to your need.

If you want easier solution, you can use plugins. This is the plugin I recommend to you for easier solution:

Recent Posts Widget Extended

Using this plugin you can list posts according to your needs in widget as well as you can get shortcodes too. And you don't need to style those posts by yourself.

0

This plugin may be what you are looking for https://wordpress.org/plugins/list-category-posts/.

You can display the posts from specific categories using the shortcode [catlist name="category"]

It has all other settings you need to display posts from a category using different parameters. It also works on the widget using the text widget and you can display the posts you want using a category id. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.