I haven’t yet seen any discussion of this point in Phil’s post below, so I wanted to highlight it again:
Some of the review team have brought it up that there should be a time limit for non-updated themes, our general consensus is 2 or 3 major revisions of WordPress before suspension for not keeping themes updated. What this means that currently we’re on WordPress 3.0 previous to that was 2.9, 2.8 which is 2, 2.7 being 3 revisions previous, all themes that are prior to 2.7 (or 2.8) should be suspended as being currently obsolete.
To be clear, the Theme Review Team is formally proposing an obsolescence Guideline, that any Theme not updated within 2 (perhaps 3) major releases of WordPress be automatically suspended, until a current version is submitted and approved.
For example, if this guideline were put into place with a timeline of 3 major WordPress releases, when WordPress 3.1 is released, all Themes not updated since before the release of WordPress 2.8 (i.e. since June 2009) would be blanket-suspended.
Or, if this guideline were put into place with a timeline of 2 major WordPress releases, when WordPress 3.1 is released, all Themes not updated since before the release of WordPress 2.9 (i.e. since December 2009) would be blanket-suspended.
We very much want input and feedback on this proposal. Would this guideline generally help or hurt – improve or worsen – the Theme Repository? Is the proposed timeline (2 or 3 major WordPress releases, which translates into, generally speaking, 6 or 9 months) reasonable?
Andrew Nacin 3:23 pm on December 14, 2012 Permalink |
I’d say recommended, until WordPress itself declares that query_posts() is`_doing_it_wrong().
Chip Bennett 3:25 pm on December 14, 2012 Permalink |
What would the benefit be of making it only *recommended*?
Whether core flags the function itself as _doing_it_wrong() or not, it is always a bad practice, leads to unexpected results, and causes problems for the end user.
scribu 3:37 pm on December 14, 2012 Permalink |
Using the ‘pre_get_posts’ filter incorrectly can also lead to unexpected results and cause problems for the end user.
It’s actually easier to use query_posts() correctly than to add all the appropriate checks to a callback hooked into ‘pre_get_posts’.
Daniel 3:40 pm on December 14, 2012 Permalink |
This is a good point. The ‘request’ filter was built for the specific reason to alter the main query and the main query only; only problem is its implementation is still not complete. I propose we don’t push this as required until we are sure we have a bulletproof workaround.
Chip Bennett 3:53 pm on December 14, 2012 Permalink
$query->is_main_query()works as intended…Chip Bennett 3:52 pm on December 14, 2012 Permalink |
True. But then, so can calling
wp_nav_menu()incorrectly (e.g. by passing ‘menu’ instead of ‘template_location’). But we don’t allow Themes to usewp_list_pages()/wp_page_menu()/wp_list_categories()in place ofwp_nav_menu(). Instead, we educate about proper usage ofwp_nav_menu().Konstantin Kovshenin 7:04 pm on December 14, 2012 Permalink |
That’s so true!
Konstantin Kovshenin 3:25 pm on December 14, 2012 Permalink |
I’d go for recommended too, but huge +1 on the initiative!
Chip Bennett 3:28 pm on December 14, 2012 Permalink |
My problem with *recommended* is that, when query_posts() is used, it is almost *never* used *properly*. So, in order to pass the review process, the reviewer will have to help the developer rehabilitate the use of query_posts(), instead of simply requiring the cleaner, proper implementation via WP_Query or pre_get_posts.
Instead of teaching developers how to rehabilitate query_posts() usage, wouldn’t it be a far better use of our time to teach *proper* usage of best-practice methods?
Maor Chasen 8:29 am on December 21, 2012 Permalink |
I agree. I think that for some developers it will take a while to realize that
query_posts()is not the correct method, and if we don’t make it required now, then by the time it is being marked as_doing_it_wrong()in core — developers will still use it. IMHO, there are things that you don’t postpone, and this one is among them. Because if we don’t, it’s not just that we’re not teaching developers how they *should* do it, but end users might suffer from endless bugs that will be directly caused by the misuse ofquery_posts().Daniel 3:29 pm on December 14, 2012 Permalink |
The only problem I see is with pagination. Functions like next_posts_link() and previous_posts_link() work directly with the $wp_query and $paged globals so to get them to work one needs to alter the main query.
Konstantin Kovshenin 3:31 pm on December 14, 2012 Permalink |
That’s easy, just delete 404.php and pagination will work again, haha! How about wasted resources?
Daniel 3:32 pm on December 14, 2012 Permalink |
Is this a joke? 404 HTTP status is triggered in the page headers before templates are loaded.
Konstantin Kovshenin 3:35 pm on December 14, 2012 Permalink |
Of course it’s a joke, while I’ve seen a few people do it. You should never, never, never use query_posts. Period.
scribu 3:40 pm on December 14, 2012 Permalink
You should never, never, never use query_posts(), unless there’s no better way to do it. That’s why it’s not deprecated in Core, yet.
Chip Bennett 4:01 pm on December 14, 2012 Permalink
@scribu: examples of cases where there is no better way to do something than via
query_posts()?That’s the paradigm shift I’m struggling with, here.
scribu 4:10 pm on December 14, 2012 Permalink
The exact use-case that query_posts() was designed for: using a custom page template as an archive of posts:
Just call query_posts() at the very beginning and pretend it’s an arhive. query_posts() takes care of completely replacing the main query and the effect is limited to that custom page template.
You don’t have to do any workarounds for conditional flags or for pagination.
scribu 4:11 pm on December 14, 2012 Permalink
Chip Bennett 4:12 pm on December 14, 2012 Permalink
So, pagination works “out of the box” on a custom page template where the default query is stomped by
query_posts()?Chip Bennett 4:18 pm on December 14, 2012 Permalink
Also, I note that even you say that using
WP_Query()is the better method for creating secondary loops:nofearinc 6:05 pm on December 14, 2012 Permalink
what’s the preferred way to handle pagination though? It’s indeed using the $wp_query global inside of the pagination definition and passing arguments from the outside is a bit odd. There is no valid way to overload the query variable used for the pagination functions.
Chip Bennett 3:34 pm on December 14, 2012 Permalink |
Isn’t that an argument in *favor* of using
pre_get_postsinstead ofquery_posts()? If you alter the main loop query *before* the query is set up, pagination just works.Daniel 3:37 pm on December 14, 2012 Permalink |
That works for most cases with one exception I’m aware of: custom page templates. If you want to display a custom loop in a page template you need the main loop unaltered before the template is loaded to make sure the correct one is loaded. Otherwise the function is_page_template( ‘some-template.php ) may not return the correct value.
Chip Bennett 3:49 pm on December 14, 2012 Permalink |
If you want to display a custom loop in a custom page template, then instantiate a custom query, via
new WP_Query().Pagination still requires a bit of a work-around, but I would contend that work-around is far less intrusive than what is required to ensure that the main loop query is replaced cleanly.
Daniel 4:14 pm on December 14, 2012 Permalink
The
paginate_links()function could be used which accepts custom pagination arguments, and simple prev/next links could be generated by setting all numbered pagination values to 0; though I see that more as a hack rather than a workaround and I wouldn’t like to see it as recommended.Daniel 4:17 pm on December 14, 2012 Permalink
What I would like to see is functions like
next_posts_link()andprevious_posts_link()accept query objects as optional parameters. I believe that would be a huge enhancement in core.