Forums Forums Search & Filter Pro Help with WP_Query not working

Viewing 10 posts - 21 through 30 (of 33 total)
  • Trevor
    #167932
    This reply has been marked as private.
    Anonymous
    #167939
    This reply has been marked as private.
    Trevor
    #167941

    It looks like your theme is not searching in the testimonials CPT. If I do this search:

    https://voxscientia.eu/?s=scipost

    Not results are found either, but searching for data or digital finds only the home page.

    Maybe you could add Relevanssi (free version) and set that up to search the testimonials CPT? Build the index then enable to setting in the S&F form Advanced settings.

    Anonymous
    #167947
    This reply has been marked as private.
    Trevor
    #167961

    Taking a step backwards, if you use a plugin like CPT UI and create a test post type (making sure it is set to be visible to WP Search), make a post in it, and do a standard WP search, does the theme find it? If not, try switching to 2016 theme and test.

    Anonymous
    #167963

    The site is live already so I can’t really afford switching theme.

    I’ll try with the new post type though and will keep you posted

    Anonymous
    #167966

    All right, the answer is no, I can’t search the new post type either

    Trevor
    #167972

    That suggests something odd with the theme. Are you able to copy the site to a test domain?

    Anonymous
    #167977
    This reply has been marked as private.
    Trevor
    #167981

    I wrote this little bit of code, which would do it:

    function dontsearchCPTs($query) {
     
    if ($query->is_search) {
      $query->set('post_type', 'post');
    }
      return $query;
    }
    add_filter('pre_get_posts','dontsearchCPTs');

    That would stop search looking at anything other than plain posts. I guess there might be other ways.

Viewing 10 posts - 21 through 30 (of 33 total)