• Hi, I’m sorry if this is a silly question or outside the scope here
    The default recent posts shows posts from all categories. And there is no option to filter them by category.

    So How to display recent posts from a specific category on the Homepage.

    I don’t have much experience with PHP but I found this code on a site

    <?php $catquery = new WP_Query( 'cat=72&posts_per_page=5' ); ?>
    <ul>
     
    <?php while($catquery->have_posts()) : $catquery->the_post(); ?>
     
    <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
    <?php endwhile;
        wp_reset_postdata();
    ?>

    But I don’t know where to add it? and how to style the post cards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    we recommend using the WP Show Posts plugin – with it you can create custom queries and control post styling:

    https://www.ads-software.com/plugins/wp-show-posts/

    The plugin is lightweight

    Thread Starter vikral

    (@vikral)

    Hi,
    This plugin uses a shortcode and PHP function to display the post.
    Ok, but where to add that? I mean I need to create a separate homepage? how to do this with a child theme?

    • This reply was modified 4 years, 5 months ago by vikral.

    You would simply create a static Page and set that as your Home Page. Then you can add the WP Show Posts shortcode.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Display Recent Posts From A Specific Category In Homepage’ is closed to new replies.