arras-theme icon indicating copy to clipboard operation
arras-theme copied to clipboard

Pagination error on the Home page news items section [moved]

Open zyml opened this issue 12 years ago • 0 comments

This is Issue 123 moved from a Google Code project. Added by 2011-03-20T09:52:27.000Z by [email protected]. Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium

Original description

<b>What steps will reproduce the problem?</b>
1. Select News Posts to appear on the home page
2. Choose a category to display with only a single post
3. Display the home page.

<b>What is the expected output? What do you see instead?</b>
Expected. A single post displayed with no pagination.
Instead. A single post displayed with an &quot;older entries&quot; link. Moreover on pressing the link all posts are displayed, not just the post(s) in the required category. 
<b>What versions of WordPress and Arras Theme are you using?</b>
Wordpress 3.1 - Arras 1.5.0.1

<b>Please include the link to your installation.</b>
The site is still under development.

<b>Please provide any additional information below.</b>

I believe the problem is caused by the call to wp_reset_query at the end of arras_render_posts. My analysis is as follows:

home.php
--------

When this is called $wp_query and $wp_the_query are referencing the &quot;default&quot; query (all posts).
Line 64 - query_posts instantiates a new WP_Query for the &quot;News&quot; category referenced by $wp_query.
Line 65 - arras_render_posts uses $wp_query to display the News posts BUT (in template.php line 166) the final call to wp_reset_query resets $wp_query to the default query.
Line 66 onwards - pagination is called operating on the default query and produces the wrong results.

It seems to me that the call to wp_reset_query is incorrect. Pagination will not work following arras_render_posts if the query referenced by $wp_query is changed, and most calls to it are followed by pagination. The bug is not more widespread because arras_render_posts is called most often when $wp_query is referencing the &quot;default&quot; query (ie $wp_query and $wp_the_query are the same) where the call to wp_reset_query is superfluous.

zyml avatar Aug 06 '12 17:08 zyml