Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8711439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:52:38+00:00 2026-06-13T04:52:38+00:00

I have set 10 posts to display per page from WordPress admin panel, but

  • 0

I have set 10 posts to display per page from WordPress admin panel, but I want to dispaly 11 posts on first page and in my case its homepage. So I want to display 11 posts on homepage and for all other pages I want to display 10 posts.

I am trying to achieve it with this code but is_home() always return true regardless of page number.

function home_custom_query( $query ) {

    if (  is_home() )
    {
        $query->query_vars['posts_per_page'] = 11; 
    }

    return $query; 
}
add_filter( 'pre_get_posts', 'home_custom_query' );  

But above code change the number of posts for all pages including homepage.

I also tried this to detect page number and tried as below

function home_custom_query( $query ) {

    if (  is_home() && $query->query_vars['paged'] == 0)
    {
        $query->query_vars['posts_per_page'] = 11; 
    }

    return $query; 
}
add_filter( 'pre_get_posts', 'home_custom_query' ); 

it changes posts per page to 11 for homepage but displays nothing on all other pages.

I also tried the cbnet-different-posts-per-page plugin which fulfills the purpose but it add some extra functionality which I don’t want to use. I need a simple solution for my problem. And I am sure there will be a neat and clean way to solve this issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:52:40+00:00Added an answer on June 13, 2026 at 4:52 am

    I did it as follows, might be helpful for you as well.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $page_num = $paged;
    if( $paged >1 ) 
        $showposts = 10; 
    else 
        $showposts = 11;
    query_posts('showposts=' .$showposts. '&paged='.$page_num);
    ?>
    
    
    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?> 
           // WordPress loop
        <?php endwhile; ?> 
    <?php endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page on wordpress where i want to display 10 random posts.
I have a page set up to show only posts from one category, which
So I have my blog set up to pull posts from my database in
I have a View set to grab the latest forum posts. That's working fine,
I'm trying to set up my EF Model. I have 2 tables: Posts and
I want to have a set of checkboxes that use AJAX to post to
I have a News page that displays all the posts within the News Category.
I have all my posts set up in certain categories. I would like to
I have to show all the posts from custom type post on my product
I have set up a site using Wordpress as my CMS. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.