[theme-reviewers] Feedback on use of query_posts please-Badidea?
Zulfikar Nore
zulfikarnore at live.com
Sat Sep 14 12:41:35 UTC 2013
"ZGani - take note here: on the static page assigned to display the blogposts index, any custom page template assignment is ignored. So, whether or
not you assign a custom template to that page, WordPress is going to use
either home.php or index.php to render that page."That is where I was getting stamped and didn't know why - totally makes sense now with that explanation. Appreciated :)
Given the way I intended to have the theme and what users have asked for I think template-featured.php is way to go rather than front-page.php.
Once again thanks Chip - I now have an implementation to take forward for my future themes :)
Zulf
Date: Sat, 14 Sep 2013 08:19:55 -0400
From: chip at chipbennett.net
To: theme-reviewers at lists.wordpress.org
Subject: Re: [theme-reviewers] Feedback on use of query_posts please-Badidea?
Not really. In the OP, the custom page template was an intended solution/implementation. The root issue was display of the blog posts index on a page other than the site front page.
The problem is that the intended solution/implementation was incorrect, thereby causing the pagination problems. Basically, if you're using template files the way WordPress expects, then WordPress properly handles the $query for the given context - including pagination.
Pagination is only an issue if a custom page template is used to circumvent core WordPress handling of the blog posts index (i.e. a template-blog.php). If you're using home.php, and have the user properly configure "front page displays", "front page", and "posts page", then you won't see any pagination issues.
The issue arises when using template files other than the way WordPress expects, such as using a custom page template to display the blog posts index. In that circumstance - a custom page template - WordPress sees the main $query as the static-page post, and applies the pagination to the static-page post. Any secondary query, regardless of how it's added, will have no impact on pagination - thus requiring a pagination work-around.
But if you rename template-blog.php as home.php, and instruct the user to configure settings -> reading properly, then WordPress recognizes the static page assigned as the "posts page" as the blog posts index, uses the home.php template to render it, recognizes $query as the blog posts index, and applies pagination properly to the blog posts index.
On Sat, Sep 14, 2013 at 7:54 AM, Philip M. Hofer (Frumph) <philip at frumph.net> wrote:
the template is what we were talking about but making pagination work for
it since it’s not a pregenerated loop
From: Chip Bennett
Sent: Saturday, September 14, 2013 4:50 AM
To: Discussion list for WordPress
theme reviewers.
Subject: Re: [theme-reviewers] Feedback on use of query_posts
please-Badidea?
There are multiple options, including conditional statements inside
front-page.php and filtering front_page_template; but don't forget: you don't
*have* to use front-page.php at all.
You can omit it, and package template-featured.php as a custom page
template. That way, the user has the control/option to use the featured content
template on the front page or on a different page, as well as the control/option
to use the featured content template or a default static page on the site front
page.
On Fri, Sep 13, 2013 at 11:06 PM, Philip M. Hofer
(Frumph) <philip at frumph.net> wrote:
The big question at this point being that front-page.php if included with
theme though overrides the index.php on all counts but I don’t want it
distributed that way ;/ how would you counter that?
From: Philip M. Hofer (Frumph)
Sent: Friday, September 13, 2013 8:04 PM
To: Discussion
list for WordPress theme reviewers.
Subject: Re: [theme-reviewers] Feedback on use of query_posts
please-Badidea?
So front-page.php basically template redirects ‘overrides’ the page that
you set it to then? and the blog loop uses the pre-get-parser at
that point on it?
Damn, well yeah I was doing it wrong. (sorry chip)
From: Chip Bennett
Sent: Friday, September 13, 2013 7:48 PM
To: Discussion
list for WordPress theme reviewers.
Subject: Re: [theme-reviewers] Feedback on use of query_posts
please-Badidea?
You don't assign front-page.php to a static page, because
front-page.php isn't a custom page template. In fact, front-page.php should
*not* even have a "Template Name:" phpDoc header (which is what would allow it
to be assigned to a static page).
The front-page.php template file is used contextually by WordPress, as
per the Template Hierarchy, based on settings -> reading -> "front page
displays" and "front page".
On Fri, Sep 13, 2013 at 10:42 PM, Philip M. Hofer
(Frumph) <philip at frumph.net> wrote:
(snicker) guess I’ am doing it wrong then, because that has never
worked for me to assign front-page.php to a static page it has always
overwritten the main
From: Zulfikar Nore
Sent: Friday, September 13, 2013 7:32 PM
To: Theme
Reviewers
Subject: Re: [theme-reviewers] Feedback on use of query_posts
please -Badidea?
Ah, progress....Now I'm getting the hang of front-page.php
:)
Date: Fri, 13 Sep 2013 22:30:14 -0400
From: chip at chipbennett.net
To: theme-reviewers at lists.wordpress.org
Subject: Re:
[theme-reviewers] Feedback on use of query_posts please -Badidea?
Both front-page.php and home.php are templates, defined in the
Template Hierarchy. What they are not, however, is custom static-page
templates. WordPress provides a core method to assign a static page to the
front page and to display the blog posts index, and the Template Hierarchy
defines which template files are used to render those contexts.
To answer your specific question: when a user selects "static page" for
"front page displays, and then assigns static pages to the front page and
posts page, WordPress will use front-page.php to render the front page, and
home.php to render the posts page.
On Fri, Sep 13, 2013 at 10:27 PM, Zulfikar Nore <zulfikarnore at live.com> wrote:
Neither of which are templates.
front-page.php will be picked up first so where will home.php fit
in?
Date: Fri, 13 Sep 2013 22:24:49 -0400
From: chip at chipbennett.net
To: theme-reviewers at lists.wordpress.org
Subject: Re:
[theme-reviewers] Feedback on use of query_posts please -Badidea?
That other page is... (wait for it...)
home.php
On Fri, Sep 13, 2013 at 10:23 PM, Philip M. Hofer (Frumph) <philip at frumph.net> wrote:
Okay so you have it "HALF” right .
the second part of that is to have the BLOG LOOP on another
PAGE
get it yet?
From: Chip Bennett
Sent: Friday, September 13, 2013 7:14 PM
To: Discussion list for WordPress theme reviewers.
Subject: Re: [theme-reviewers] Feedback on use of
query_posts please -Badidea?
No, I think I have it exactly:
"But
I've had a lot of requests for options to hide certain sections and one
of them was the blog feed on front page."
On Fri, Sep 13, 2013 at 10:12 PM, Philip M. Hofer (Frumph) <philip at frumph.net> wrote:
Yeah, you’re not getting it.
It’s not for the front page
From: Chip Bennett
Sent: Friday, September 13, 2013 7:11 PM
To: Discussion list for WordPress theme reviewers.
Subject: Re: [theme-reviewers] Feedback on use of
query_posts please - Badidea?
index.php is NOT the front page template, and should not
be used as such. It is the default fallback template.
Use front-page.php for your front page template, and home.php for
your blog posts index template. Then all of your issues go away,
magically. :)
On Fri, Sep 13, 2013 at 9:48 PM, Zulfikar Nore <zulfikarnore at live.com> wrote:
I'm using the index.php showing featured content at the
top followed by the blog feed - which works fine and I had planned
to stick with that. But I've had a lot of requests for options to
hide certain sections and one of them was the blog feed on front
page.
template.blog.php is to open the option to still have a page
with the blog feed on it when the user has opted to hide them on the
front.
Long story short - user hides posts on front but still wants a
blog fed page and this is my attempt to fill that need.
Date: Fri, 13 Sep 2013 21:42:43 -0400
From: chip at chipbennett.net
To: theme-reviewers at lists.wordpress.org
Subject: Re: [theme-reviewers] Feedback on use of
query_posts please - Bad idea?
Why do you need template-blog.php when there is
home.php for exactly that purpose?
On Fri, Sep 13, 2013 at 8:22 PM, Zulfikar Nore <zulfikarnore at live.com> wrote:
I've read around that using query_posts is bad but
I've seen many a themes using it and get away with it.
My case is I'm trying to put together a template-blog.php for
StrapVert and this is what I've come up with so far:
add_filter('option_show_on_front', '__return_false');
global $wp_query;
query_posts(array(
'paged'
=> $wp_query->get('paged'),
'post__not_in' => get_option('sticky_posts'),
));
global $more; $more = 0;
get_template_part('index-blog');
$more = 1;
remove_filter('option_show_on_front',
'__return_false');
wp_reset_query();
wp_reset_postdata();
But before I add these changes to the theme and submit an
update I'd like some feedback on "How Really Bad" is query_posts
and can I "get away" with the above?
Thanks in advance,
Zulf
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing list theme-reviewers at lists.wordpress.org http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing list theme-reviewers at lists.wordpress.org http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing list theme-reviewers at lists.wordpress.org http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing
list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing
list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing
list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers
mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing
list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20130914/5d8cc629/attachment-0001.html>
More information about the theme-reviewers
mailing list