• I want to display the last 4 posts of a single category from the module which displaying Recent Posts in the front page.
    I think, I shoud add a criteria in components/features/recent-posts/ recent-posts.php
    I think, I shoud add a criteria in components/features/recent-posts/ recent-posts.php

    <?php
    	$recent = new WP_Query( array(
    		'posts_per_page'      => 4,
    		'no_found_rows'       => true,
    		'ignore_sticky_posts' => true,
    	) );
    ?>

    It is the right way to add : ‘category-id’ => 5 in the list of criteria ?
    Thank you for your help

Viewing 3 replies - 1 through 3 (of 3 total)
  • sacredpath

    (@sacredpath)

    Automattic Happiness Engineer

    Hi there, I would have a look at this page on Category Templates, and scroll down to “What categories do you show to the visitors?” and see if that helps.

    Thread Starter makai93

    (@makai93)

    Hi,
    In child-theme, I copied recent-posts.php and I modified this :

    $recent = new WP_Query( array(
    	'posts_per_page'      => 4,
    	'cat' 		=> 5, // I added this criteria
    	'no_found_rows'       => true,
    	'ignore_sticky_posts' => true,
    ) );

    Now it’s ok

    If it can be of use to somebody

    Thank you

    sacredpath

    (@sacredpath)

    Automattic Happiness Engineer

    Awesome, and you are welcome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Displaying Recent Posts in the front page of a single category’ is closed to new replies.