[resolved] pre_option_posts_per_page filter example code not correct (3 posts)

  1. artcoder
    Posted 2 years ago #

    The code in this codex page for "pre_option_posts_per_page" filter is not correct ...

    Because I copied the code verbatim in attempt to alter the amount of displayed posts per page for a specific category. And the code did not take effect (although there was not error in output).

    Can someone who knows enough about wordpress core tell me the correct code for doing this?

  2. bcworkz
    Posted 2 years ago #

    The code example works fine for me. Be sure you provide a category slug that actually exists in your installation. Despite the name 'category_name' it is actually looking for a slug.

    It may be your theme or a plugin is overriding the posts per page value so that this filter does not work. Try adding the filter with a larger priority number. If that doesn't work, it could take some serious digging to find out where the override is happening.

    If you really need to override the posts per page for a specific reason, there may be other ways to try an override that might be more effective, depending on where this is actually needed.

  3. artcoder
    Posted 2 years ago #

    You're right. It works now (when I use the category slug). Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic