• Resolved Mark S

    (@southerncreative)


    I need help understanding category pages. I can categorize my posts by subject which creates archives following the structure:

    sitename/category/tag/page/#

    This keeps all the posts on the same page. However, I’d like to show a certain amount of posts, then use a previous/next button to go to the next page.

    It would be great to have something like Defector.com

    https://defector.com/category/nhl?after=YXJyYXljb25uZWN0aW9uOjE0MDM5MA==

    Is this something a plugin can handle?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    show a certain amount of posts, then use a previous/next button

    That is usually normal theme behavior. The posts per page is defined in reading settings and the previous/next links are output with something like the_posts_navigation();
    Certain themes can deviate from this. If yours does, I suggest asking through your theme’s dedicated support channel for how this could be accomplished with your particular theme. Or find a theme that works this way by default.

    It’d be difficult for a plugin to implement this since all themes manage how they work differently. It’s possible to override a specific theme’s behavior via plugin, but not to do so for any random theme someone uses.

    Thread Starter Mark S

    (@southerncreative)

    Thanks for your response, @bcworkz

    I’m not quite sure if we’re talking about the same thing. Reading settings are for post pages, not category pages. Is that correct? I’ve already contact the theme support and they said category pages are generated by WordPress automatically and suggested hiring a third-party developer.

    What language would I even use to narrow my search, PHP?

    Moderator bcworkz

    (@bcworkz)

    The “Blog pages show at most” setting is poorly labeled. By default the setting is applied to any archive listing. However, various themes and plugins often override this, so the setting is not guaranteed to be used in any particular archive listing. It can be overridden by altering the “posts_per_page” query var for WP_Query. It’s directly used in the LIMIT clause in SQL.

    It looks like your current page initially loads 10 matching posts, likely your reading setting’s quantity. On scroll it then lazy loads more posts, probably 10 more at a time if you have that many posts in the category. So you probably don’t need to alter the query itself, but you would have used PHP if you needed to do so.

    To convert lazy load to pagination behavior you need to remove the lazy load script from the page and add page navigation code to the template. Assuming your theme’s templates are .php based, you can try adding <?php the_posts_navigation(); ?> to the correct template where you want the nav links to appear. If you’re not sure which template, try using the Template Debugger plugin.

    The tricky part will be in removing the lazy load script. Determine where in your theme’s PHP code it enqueues the lazy load script. It should use the wp_enqueue_script() function (that references a .js file somewhere). If you can locate the right function call, disable it by making it into a PHP comment.

    If the enqueued script does more than just providing lazy load functionality, by removing the enqueue code you’ll also lose what ever other functionality is involved. To retain other functionality you’d need to remove the lazy load portion of the JS source code instead of simply commenting out the enqueue code.

    Thread Starter Mark S

    (@southerncreative)

    Amazing response, @bcworkz ! Thanks so much! But this goes far beyond my capabilities. I did use your recommendation on a different theme, and discovered that defector.com uses a theme called Lede, but my site doesn’t have any traffic to justify it. I may go with a themeforest theme called SmartMag if that helps anyone else.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change category pages view from scrolling to previous/next’ is closed to new replies.