• I need help making the loop display 5 posts on the first page and then 6 on the subsequent pages. The code example I’ve added to pastebin enables me to style the latest post differently to the rest (this is important). I need to combine that (styling latest post differently) with the conditional post_per_page (5 on page 1 and 6 on page 2,3, 4 and so on…)

    I’ve been trying for hours but to no avial – so I’m asking the community for help.

    http://http://pastebin.com/zWZYWF0R

    Thanks

    Dan

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter surfsup74

    (@surfsup74)

    Sorry my pastebin url didn’t work in the last post! Try this…
    http://pastebin.com/zWZYWF0R

    Thread Starter surfsup74

    (@surfsup74)

    Thanks –
    I copied your code but got an error message:

    Parse error: syntax error, unexpected T_VARIABLE in D:\xampp\htdocs\path_to_file\index.php on line 17

    Any ideas why please?

    Misplaced single quote. Try http://pastebin.com/5xmkTXSc

    Thread Starter surfsup74

    (@surfsup74)

    Ah. Thanks. The post per page now works exactly as I wanted – however, every post is now being given the ‘first entry’ class.

    Thread Starter surfsup74

    (@surfsup74)

    Thanks for that Esmi! Its not quite right though – sorry – I should have explained more clearly. I wanted only the very latest post to be give the class ‘first entry’ then every other post should be class of ‘other-entries’. Using your code all the posts in the first page are given the class ‘first entry’ and then the post on subsequent pages are given the style ‘other-entires’, which is not quite right.

    Also – the loop is missing out a post. I currently see the 5 latest posts on page 1 (post 1 – 5) and then on page 2 I see posts 7 – 12. This is missing out post 6 (?).

    Thanks again…

    Thread Starter surfsup74

    (@surfsup74)

    I have amended Esmi’s code slightly (see pastebin link below) and now have the latest post given the ‘first entry’ class and every other post ‘other-entries’ class (as intended).

    The only thing to now resolve is the missing post?! When on the first page of posts I see five posts (say posts number 1-5 – which is correct) however page 2 starts with post number 7 (so it seems to be skipping post number 6).

    Any ideas why please…

    http://pastebin.com/SMabySE9

    Coffee4cr

    (@coffee4cr)

    I have the same “problem” but the other way around.

    I have 9 post displaying on the first page, and 8 on the next ones. so on page 2, I see my last post of page 1. but it doesn’t happen on other pages.

    Here’s the reason why, but haven’t figured out the way to fix it yet.

    What’s happening is when you switch your posts_per_page parameter, WP recalculates its offset from that new parameter.

    So let’s say in your case you have 5 on the first page and 6 on subsequent page.

    It’s going to show you 1-5 on page 1, but then when you go on page two, and ask for 6 instead, WP will think you had 6 on the first page, hence why you’re getting 7-8-9-10-11-12 on your page 2

    Coffee4cr

    (@coffee4cr)

    found this, http://pastebin.com/51r7PTwb
    and it fixed my problem.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Help displaying different number of posts_per_page on page 1’ is closed to new replies.