For the same post, I have suddenly a weird behaviour of single.php file between normal user and administrator.

In the beginning of the loop, I perform:

echo '<pre dir="ltr">';
echo '</pre>';

And the result is different.

In the case of administrator:

[queried_object_id] => 603
    [request] => SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.post_name = 'test' AND wp_posts.post_type = 'aya-bi-aya'  ORDER BY wp_posts.post_date DESC 

In the case of non-administrator:

[queried_object_id] => 0
    [request] => SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'aya-bi-aya' AND (wp_posts.post_status = 'publish')  ORDER BY wp_posts.post_date DESC LIMIT 0, 10

I spent one day and a half trying to figure out what can be the reason behind this dysfunctionning, but in vain. Your time is really invaluable.

  • 2
    Poorly written filter? query_posts breaking things? Perhaps the code for the problem page would help. – s_ha_dum Nov 10 '13 at 14:22
  • You really rescue many people on this earth S_HA_DUM!!. You are right, when I isolated my sidebar (which contains query_posts many instances), the problem was resolved. Now I am going to replace query_posts. Thank you very much for your smart help. I am waiting for it as an answer. – whiteletters in blankpapers Nov 11 '13 at 8:14

Per a comment, the problem was due to the use of query_posts which clobbers the main query.

Please don't use query_posts.

It should be noted that using this to replace the main query on a page can increase page loading times, in worst case scenarios more than doubling the amount of work needed or more. While easy to use, the function is also prone to confusion and problems later on. See the note further below on caveats for details.

http://codex.wordpress.org/Function_Reference/query_posts (emphasis mine)

In addition, it overwrites $wp_query which the main Loop on the page uses.

If you need additional loops use a new WP_Query object, not query_posts.

  • 1
    +1. And this is the reason that I downvote any and every answer I see that uses query_posts(). – Chip Bennett Nov 11 '13 at 16:05
  • Thank you S_HA_DUM. What would the Earth be like without people like you?? – whiteletters in blankpapers Nov 15 '13 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.