jeudi 1 janvier 2015

WP_Query for BBPress Topic When Parent is Private/Hidden


I have the following Code:



$widget_query = new WP_Query( array(
'post_type' => 'topic',
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'),
'post_status' => 'inherit',
'post_parent' => (int) $settings['parent_forum']
));


When the actual post (forum topic) $settings['parent_forum'] is set to post_status 'publish' this works correctly, if I change it to 'private' the code doesn't return any topics at all. WP_query is doing checking on the post_parent to check for visibility. Not allowing me to get to any of the posts under the parent.


I want to enable guests and all users to view these topics in a piece of custom code. How can I allow this? I only want to allow this query that kind of access as it is providing a summary to my users. I am basically re-using a forum topic. I am hiding the topic from the forum view making it 'private' and wanting to select the threads within. This all works if I am logged in as the administrator on the site - but as soon as Im a guest or registered user, it doesn't work. I could just fire up some basic mysql_connection to get to the data I want but I would prefer not to!


Any guidance would be great.





Aucun commentaire:

Enregistrer un commentaire