• I’m unable to figure out why my wp_query and query_posts queries are only working for the administrator. My natural suspicion was it was caching (I’m using WP Total Cache), however the queries are not working correctly for other logged in users, only the admin.

    here’s an example:
    http://picturesfor.me/album-categories/animals

    All users are seeing all the thumbnails on the left, and all 4 album listings on the right, whereas the admin user only sees the (correct) 2 thumbnails on the left, and 1 album listing on the right.

    here is my query running the thumbnails:

    $args = array(
    'posts_per_page'=> -1,
    'tax_query' => array(
    array(
    'taxonomy' => 'gallery-categories',
    'field' => 'tag_ID',
    'terms' => $cur_cat_id
    )
    )
    );

    and here is my query for the album posts:

    $args = array(
    'post_type' => 'albums',
    'order' => 'DESC',
    'tax_query' => array(
    array(
    'taxonomy' => 'album-categories',
    'field' => 'term_id',
    'terms' => get_cat_id( single_cat_title("",false) )
    )
    )
    );

Viewing 5 replies - 1 through 5 (of 5 total)
  • Long shot – have you set the album post type to be public?

    Thread Starter chrisipeters

    (@chrisipeters)

    thanks for taking the time to reply but I don’t understand why this would make the administrator see less (properly filtered) posts than other users. I’m still rather new to custom queries, so if you could explain a bit more I’d greatly appreciate it.

    They’re newish to me too, but have been working on them a bit recently. If (and its a big if!) I understand the public setting, I think it limits the ability of a user to do stuff at the front end like post queries, but if you’re admin, no limits, so you see the code working and they don’t.

    Its a theory … and I would have expected nothing to come back if it wasn’t public. It feels lke a permissions thing (obviously).

    I’m having the SAME issue with a piece of my code. I ensured that the post type is public. Any thoughts?

    Thread Starter chrisipeters

    (@chrisipeters)

    I spent days trying to fix this, and between a myriad of websites and posts, I managed to accomplish what I was trying to do. I’m sure there is a more elegant way of using wp_query to do it, but here’s what’s working for me.
    (You can see my result on http://picturesfor.me/album-categories/weddings ).

    Hopefully this helps out everyone else that is stuck in the same boat I was…

    http://pastebin.com/a4q55Sqm

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_query & query_posts only working for administrator’ is closed to new replies.