• Resolved becswright

    (@becswright)


    Hello –

    Working on tweaking my company’s website’s homepage – http://www.my-table.com – and I want to limit the number of posts that appear in the middle feature box to only the 4 or 5 most recent. I’m not a website developer by any means, but I’m sort of stuck with tweaking the website (small company, small budget).

    I believe I need to add something to the line below (but I really don’t know).

    ‘<?php $features = new WP_Query( array( ‘post_type’ => ‘sidedish’,’post__in’ => $sidedish_posts_to_query ,’order’ => ‘DSC’) );?>’

    Any help would be appreciated!

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter becswright

    (@becswright)

    Actually I think somewhere in the lines below?

    <?php $features = new WP_Query( array( 'post_type' => 'sidedish','post__in' => $sidedish_posts_to_query ,'order' => 'DSC') );?>
                            <?php if ($features->have_posts()) : while ($features->have_posts()) : $features->the_post(); ?>

    You need to add another query into the WP_Query :-

    ‘posts_per_page’ => ‘4’

    So it should look like this

    <?php $features = new WP_Query( array( 'post_type' => 'sidedish','post__in' => $sidedish_posts_to_query ,'order' => 'DSC', 'posts_per_page' => '4') );?>
                            <?php if ($features->have_posts()) : while ($features->have_posts()) : $features->the_post(); ?>
    Thread Starter becswright

    (@becswright)

    Thank you! I was overcomplicating things.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Limit number of posts on homepage’ is closed to new replies.