WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. artcoder
    Member
    Posted 7 months ago #

    The code in this codex page for "pre_option_posts_per_page" filter is not correct ...
    http://codex.wordpress.org/Plugin_API/Filter_Reference/pre_option_(option_name)

    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
    Member
    Posted 7 months 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
    Member
    Posted 7 months ago #

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

Reply

You must log in to post.

About this Topic