Custom Post Limits v2.6

I’d lke to announce the official release of the updated Custom Post Limits plugin (v2.6) for WordPress.

Control the number of posts that appear on the front page, search results, and author, category, tag, and date archives, independent of each other, including specific archives.

This release features a reversion to the v2.0 method of post limiting, but with a fix for individual archive limiting (ostensibly the primary thrust behind the v2.5 release, but the approach used in that release caused other conflicts). It also adds the ability to “Reset Settings” and other minor tweaks and code documentation.

The plugin’s official homepage is located at :
coffee2code.com/wp-plugins/custom-post-limits.

Comments welcome on this post for this version of the plugin. Comments will be closed once this release has been superseded by another.

Read more for a detailed ChangeLog of the release.

Detailed ChangeLog

These are the detailed changes, some of which may or may not make sense to you depending on your familiarity with the previous features and internals of the plugin.

  • Revert post limiting back to hooking ‘pre_option_posts_per_page’ rather than filtering ‘post_limits’ (fixes bug introduced in v2.5)
  • Fix bug related to individual author/category/tag limits not applying (the primary intent of the v2.5 release, but needed re-fixing due to reversion)
  • Fix bug preventing value of individual limits from appearing on settings page (the value had been saved and used properly, though)
  • Add ‘Reset Settings’ button to facilitate resetting all limits configured via the plugin
  • Internal: add get_authors(), get_categories(), get_tags() to retrieve and buffer those respective values if actually needed
  • Update object’s option buffer after saving changed submitted by user
  • Add PHPDoc documentation
  • Update .pot file
  • Minor documentation tweaks

24 thoughts on “Custom Post Limits v2.6

  1. With version 2.5 (on WP 2.9), on a site I have in development, I had an issue with category archive pages.

    When specific category archive pages were limited with this plugin, to a certain amount of posts per page, and the archive went into several pages, some of the same posts would show up on more than one page. Think this may have been just the last page where this occurred. Where a few posts would show again.

    2.6 has fixed this issue!

    Great plugin.

  2. Where can I find version 2.5 to redownload?

    With version 2.5, when I limit the top parent category to 1 post, the page navigation isn’t displayed and with the child categories, I limit it to three posts and the page navigation is displayed if there are more than 3 posts.

    With version 2.6, now the parent category will have a page navigation to all posts to also include the child categories. Grrr!

    I thought maybe the category assigment was the issue, but it wasn’t.

    My heirachy [sp] for each top category: I only have a parent category (top) and 1 level of child categories under it. It doesn’t go any deeper. Each parent category only has one post. Each child categories has many posts.

    Each post only has one category assigned to it (I don’t assign multiple categories to one post).

    So I want to revert, can I have the earlier revision?

  3. My site has been showing 2 posts and I want it to show only 1. I downloaded your plugin and left all fields empty, but my homepage is still showing 2 posts.

  4. Roger: If you really want them, you can find the files for v2.5 here: svn.wp-plugins.org/custom-post-limits/tags/2.5/

    When I get a chance I’ll revisit the plugin with your comments in mind to see if the behavior you are describing is an error or expected. Of course, if it is an error I will seek to correct it. v2.6 by all accounts is improvement over v2.5, so it’s possible the behavior you desired was a result of a bug in v2.5. I’ll try to email you in the future if I need more feedback about what you were trying to accomplish.

  5. Jim: Downloading and installing the plugin but without configuring it will not cause any changes to your site. You must specify limits via the plugin’s settings page in order to get the limits you want. Since you haven’t specified any, the default for your site, 2, will continue to be used. If you wish your front page to show 1, you must provide that value into one of the input field for the “Front Page” limit.

  6. Hello,
    This is great, thanks. It works on all my category pages but on my home page it is not working. I set my home page limit — and my category limit — to 8 posts. On my home page there are 24 posts. Once you go to the subsequent pages there are only 8, but that home page is overloaded.

    Any insight into why this is happening? I’ve made a few pages “sticky”, too.

    Thanks!
    Alison

  7. Nice plugin but my browser crashes because ive too many authors, cats and tags! Stupid ist the link to hide/show the eg authors because i must wait until the side is loaded…

  8. Scott — Great plug-in! It’s working perfectly on my blog…but:

    I’ve set it to display 12 posts in each of the monthly archive pages. But only the first post of that month displays the full post. After that, the rest of them display the title and “Read the full article ?”

    Do you have any idea what I need to change so that ALL the posts in the monthly archive page are displayed in full?

    Thanks for any help.

  9. Thank you so much for this plugin. It is exactly what I was looking for. I wanted to make archive/tag pages have more posts since they only contain excerpts; and the front page to have less posts since it contains full-length posts. Well, Custom Post Limits does just that, works fine with WP PageNavi, and is super easy to install and configure. Thumbs up.

  10. Any plans to update this plugin for WP 3 and above? I’d love to use it, but when I install it, weird behavior starts (like regular posts failing to ever load, and my entire site grinding to a crawl). Once I deactivate the plugin (and delete the files!) things get back to normal. I did that whole process (install, activate, configure, test, panic, deactivate, delete) twice so I’m 99% sure it’s this plugin that’s causing it.

    Reckless of me, I know, to install it on WP3 when it clearly says it’s not tested on that version, so I’m hoping you have plans to update it as the functionality is exactly what I’m looking for.

    Thanks!

  11. Hi there,
    I’m trying to implement your plugin “custom post limits” but I’ve run into two snags

    1. it displays “older posts/newer posts” at the top and bottom. Is there anyway to do it at the bottom

    2. where do I go to style the link and/or add a class to it.

    Thanks!

  12. Joe: Sounds like you need to modify the theme template file used to render your monthly archives. The precise file used can vary depending on the theme. You can try using my Reveal Template plugin to help figure out which is in use, and change that.

    This plugin only controls the number of posts shown (which it sounds like it is doing correctly in your case) and not anything related to how they are shown.

    illi, Kermit: An update is in the works to reduce the excessive load the current version causes for some people.

  13. Scott: I’m not quite sure your request is directly related to the Custom Post Limits plugin. The plugin only controls the number of posts listed on different pages of your blog. It does not output any links or markup on the front-end. The “older/newer” navigation links are usually the product of your theme or possibly a plugin (if you installed one for that purpose). The plugin only outputs stuff on its admin page.

    Unless I’ve misunderstood your question?

    If it’s the theme files you want to modify, the things you’d need to change would vary depending on the theme. If you are using a Twenty Ten based theme, you’ll find what you want in the theme’s loop.php file. Otherwise, you’ll have to review some of the theme’s files (typically index.php, archive.php, category.php, search.php, tag.php, etc) to find the navigation markup so you can remove the top one and add a class to it.

    Hope that helps!

  14. Hi Scott,

    I just installed your plugin on my site (just click my name) and it’s working like a charm. You just saved me a ton of time tonight that I would have spent trying to achieve this by customizing my theme.

    You might want to release another version number so that people will see that it was updated in 2011. They’re more likely to download it that way.

    -Paul

  15. Oh, and a feature suggestion: Another option to limit the posts on pages that are generated by the is_home() function, but are not the first page of the site.

    Here’s my situation:

    With my current site I have the default post limit set to 10. Then I used your plugin to set the “Front Page Limit” to 3.

    However, this means that all of the blog posts generated by is_home() are limited to 3. Generally speaking that means all pages generated by home.php will be limited to 3 posts. Meaning that when I click the “Older Posts” link at the bottom of the front page I’ll only see 3 posts on paulhastings.me/page/2/.

    I’d really like to see 10 posts on paulhastings.me/page/2/, paulhastings.me/page/3/, etc. but see only 3 posts on the first home page.

    This situation isn’t to be confused with the “Archives Limit” section which is working fine. A good example would be: paulhastings.me/2011/01/ . That page is generated by archive.php from the is_archive() function.

    Hopefully that all made sense. If you have any questions then just shoot me an email.

    Thanks,
    -Paul

  16. I guess this plugin is somewhat dead, just to highlight one point: The plugin is pointless if your theme uses Custom Posts and Taxonomies, this plugin wont even see them, it can only see the default Blog posts…thats too bad.

  17. I’m still getting the weird SQL errors as reported on the Custom Post Limits v2.0 post (see my comment from September 12, 2009). This is with the latest 2.6 version of the plugin.

    Here’s an example error:
    [19-May-2011 11:57:20] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘1.844674407371E+19, 9223372036854775807’ at line 1 for query SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (10) ) AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 1.844674407371E+19, 9223372036854775807 made by require, wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts

  18. Hi, I have used your excellent plugin for a variety of projects but this time it failed me. The site runs the latest WP release and have over 13 000 posts and multiple authors. Going to the settings page I’m made to wait forever and then it crashes the browser instance in Chrome 13 🙁

    Could we please please have a new updated version of this excellent tool?

  19. I’m using version 3.5 and getting a notice when using the plug-in. Here is a trivial patch to fix it:

    
    commit d8585f6f239133d0e1b3892b4f80eda87fb4809e
    Author: Leandro Lucarella <[email protected]>
    Date:   Sat Sep 3 12:35:39 2011 -0300
    
        Custom Post Limits: Avoid a notice message
    
    diff --git a/wp-content/plugins/custom-post-limits/custom-post-limits.php b/wp-content/plugins/custom-post-limits/custom-post-limits.php
    index d90c468..a6eb437 100644
    --- a/wp-content/plugins/custom-post-limits/custom-post-limits.php
    +++ b/wp-content/plugins/custom-post-limits/custom-post-limits.php
    @@ -385,7 +385,7 @@ JS;
                            $this->get_categories();
                            foreach ( $this->categories as $cat ) {
                                    $opt = 'categories_' . $cat->cat_ID . '_limit';
    -                               if ( $options[$opt] &&
    +                               if ( isset($options[$opt]) && $options[$opt] &&
                                            ( $query_vars['cat'] == $cat->cat_ID || $query_vars['category_name'] == $cat->slug ||
                                                    preg_match( "/\/{$cat->slug}\/?$/", $query_vars['category_name'] ) ) ) {
                                            $limit = $options[$opt];
    

  20. @Paul: As a belated follow-up, your requests was added to v3.5 of the plugin. Each section that can have its own custom post limit now also has the ability to separately define the front page limit for that section. So your front page can show 3 posts, whereas pages 2+ could be set to show 10 each.

  21. @Gunnar: Try v3.6 of the plugin. Now by default it does not enable support for defining limits for individual authors/categories/tags, which could cause the server to time out or the browser to become unhappy if a site had a lot of authors, categories, and/or tags.

Comments are closed.