Skip Navigation

[Closed] WP_Query failing unless Toolset access for Guest is set to Read

This support ticket is created 2 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Christopher Amirian 2 years, 2 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2622035

Hello, I am trying to query custom post types created by Toolset and managed with the Toolset Access plugin. However my query will only return results if the post type is set to guest readable, which is not what I want. I have verified that the post type is queryable and that exclude_from_search is unchecked.

$found = false;

$query = new WP_Query(array(
'post_type' => '{slug}',
'post_status' => 'publish',
'meta_key' => 'wpcf-{slug}',
'meta_value' => '{value}'
));
if ( $query->have_posts() ) {
$found = true;
}

When I enable guest access in the Access table the query returns the expected instances, but if I uncheck the guest read access then no instances are returned. Can you tell me how to get the WP_Query working with non public content? I've also confirmed that the page is being accessed by the proper user with wp_get_current_user(). One thing to note is that this role was not created in Toolset but by another plugin.

Thanks!
Adrian

#2622383

Christopher Amirian
Supporter

Languages: English (English )

Hi Adrian,

Would you please test by adding a new user role using Toolset Access and make sure that it has the "read" capability for the custom post type in question?

See if that method works for you.

Thanks.

The topic ‘[Closed] WP_Query failing unless Toolset access for Guest is set to Read’ is closed to new replies.