• Hiya!

    this is the site i am working on… https://silvermanwebdesign.co.uk/star/

    as you can see, the home page just displays the most recent post. that’s great for me. but if you click older entries, then it takes you to page 2, which also just shows 1 page. I would like it, if pages 2 onwards could display about 10 posts on it?

    i know that it’s some kinda if statement or something that i need to get working, but i need a hero to show me the way! ??

    could someone help me please?

    thanks loads in advance xxx

Viewing 8 replies - 1 through 8 (of 8 total)
  • You will need to modify the way pagination works. The code below should be placed just ahead of the loop:

    <?php $max_first_page = 3;  // Show this many posts on front page
          $args = $wp_query->query;
          $args['caller_get_posts'] = 1; // Using stickies messes up the count
          $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
          $posts_per_page = get_query_var('posts_per_page');
          $posts_to_skip = $posts_per_page - $max_first_page;
          if ($page == 1) {
             $max_posts = $max_first_page;
          } else {
             $max_posts = $posts_per_page;
             $args['offset'] = (($page - 1) * $max_posts)- $posts_to_skip;
          }
          query_posts($args);
          if ($wp_query->max_num_pages < ceil(($wp_query->found_posts + $posts_to_skip)/$posts_per_page))
            ++$wp_query->max_num_pages;
          $counter = 0;
          ?>
       <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
             <?php if (++$counter > $max_posts) continue; ?>
                 // Rest of the loop
    Thread Starter silverlulu

    (@silverlulu)

    Hi thanks for the help, unfortunately it brought up an error when i put it in before the loop.

    it gave me an error saying that my footer wasn’t being called properly.

    can anyone else help me please?

    i just need a rule that says if it’s the 1st page show 1 post, for all other pages show 10 posts or something!

    cheers ??

    What was the error? Since you seem to be using a custom theme, I can’t look at the code. Can you post the index.php in the pastebin so I can take a look?

    This code has worked in other themes, so I believe it can work here. And, unfortunately, I don’t know of a simpler solution.

    Thread Starter silverlulu

    (@silverlulu)

    hi!

    thanks for sticking with me ??

    ok so this is the error i am getting

    Parse error: syntax error, unexpected $end in /home/silverma/public_html/star/wp-content/themes/StarSignings/index.php on line 141

    – line 141 is where i call my footer, and that’s not a problem normally. it’s just the standard <?php get_footer(); ?>

    and then this is my code for index.php

    [Large code excerpt removed by moderator. Per forum rules, please post all large code excerpts in the pastebin. It works better anyway.]

    Thread Starter silverlulu

    (@silverlulu)

    ok wow forget that last post anyway cos i was an absolute moron and hadn’t piut it in right…

    it’s kinda working right now… shows 1 post on the home page, which is great but on page 2 etc… it’s messing my code up. so there seems to be an issue..

    this my website https://www.silvermanwebdesign.co.uk/star

    and this is the code for my index page now…

    https://pastebin.com/embed_js.php?i=KTsdTELa

    i think i’m close!!! please help me. thanks!

    I’m sorry, but there seems to be too much custom code for my solution to work. For example, using nav.php instead of standard WP navigation.

    It looks like you have installed the code correctly, but I could not see any previous/next page links on the site. I assume this is due to the custom nav. I really can’t suggest any other solutions. ??

    Hope someone else can be more help.

    Thread Starter silverlulu

    (@silverlulu)

    hiya,

    yeah i took out the previous/next page links because i have to preview this site to the client and didn’t want them to see it. ah god, i am scared!! haha.

    if this helps this is the link to my second page https://silvermanwebdesign.co.uk/star/page/2/

    the loop you gave me seems to work perfectly to show just one post (allowing me to show more in archives for example, but it seems to go crazy on the second page).

    i understand that i am probably annoying you but if you could help i would love you forever ??

    thank you.

    It’s not that you are annoying, it’s that I can’t see the code or test it and I am working in the dark. I am certainly willing to help if I can, but without access to the code it is almost impossible.

    The link you posted gives a 404 – Not Found error.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘want to show 1 post on home page, but more on page 2! how?’ is closed to new replies.