If the user is logged out and tries to search something, he is redirected to the login page. How is it possible to have the search always show all of the results (including the excerpts and the image), even if the user is logged out and the resulting pages/posts are restricted to members only? I tried using the plugin "WordPress Access Control", but that did not help.

  • 1
    How exactly are restrictions implemented?
    – Rarst
    Jan 16, 2014 at 20:42
  • I am using the groups plugin, and setting capabilities and groups, along with swiftype search plugin
    – vobs
    Jan 16, 2014 at 22:00
  • also I tried using another search plugin (relevanssi) and the results are now showing, but I would like to use swiftype instead. How is that possible?
    – vobs
    Jan 16, 2014 at 22:04

1 Answer 1


If you setting the posts to private in WordPress, you can add this to your functions.php file:

function include_private_in_search( $query ) {
  // not an admin page and is the main query
  if (!is_admin() && $query->is_main_query()){
     $query->set( 'post_status', array ( 'publish', 'private' ) );
add_action( 'pre_get_posts', 'include_private_in_search' );

Then you can format the search results page to show the excerpt and image.

  • Are you sure this works? "Private" posts are heavily protected.
    – s_ha_dum
    Jan 16, 2014 at 21:29
  • I have tried setting the posts to private, but then they do not appear at all at certain lists of posts I'm showing...
    – vobs
    Jan 16, 2014 at 22:02
  • @S_ha_dum I just tested it again and it is working for me.
    – hornj
    Jan 16, 2014 at 22:58
  • @vobs Try creating a page that runs that a specific query like query_posts('post_status=private'); and see if that works for you.
    – hornj
    Jan 16, 2014 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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