WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] Filter by "page" post type issue (8 posts)

  1. joero4ri
    Member
    Posted 2 years ago #

    I just installed the latest Relevanssi on my site, and everything is working perfectly except for one thing. I would like to have a list of post types that the user can filter there search results on. I have the list and and it all works except for one post type... the "page" post type. Users can filter based on the "post" post type and event my custom "event" post type, but when the user clicks on the link to filter by the "page" post type, all results are returned. Any ideas?

    Here is the querystring...
    ?post_type=page&s=test <-- returns all results
    ?post_type=post&s=test <-- returns just posts

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    I was going to say I had the same problem, but then I noticed I didn't have Relevanssi activated on my test blog. Once I activated the plugin, the problem went away and everything works like it should.

    Now, that raises the question: are you sure your search results are provided by Relevanssi? Because the way Relevanssi is coupled with WordPress is a bit fragile, it can be thrown off by something small like a single query_posts() call on the search results page.

  3. joero4ri
    Member
    Posted 2 years ago #

    I looked in my search results page and found no reference to query_posts(). I checked my results with Relevanssi deactivated and my search results are in a different order (by date). Activated Relevanssi again, and my search results changed. It seems strange that I can set my post_type to post or event, and my search results get filtered perfectly, but once I set it to page, everything comes back.

    Thanks for responding, I do believe that Relevanssi is returning my search results, is there anywhere else I should be checking?

    Thanks again.

  4. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    That's a strange thing... Sorry, I don't have any more ideas. Maybe you could put a

    var_dump($wp_query);

    somewhere on your search results page to see if the post_type parameter is passed correctly.

  5. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    Oops, looks like I'm having the same problem as well.

    I'll see what's going on. Meanwhile, I can give you a quick fix: use post_types instead of post_type. That one works for me.

  6. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    Looks like trying to set the post_type to "page" makes WordPress set it to "any". This is some sort of WordPress trickery that Relevanssi can't do anything about - since WP changes the value, Relevanssi can't tell when the user really means "any" or not. I don't think this has happened before, so it might be a new feature of 3.3.

    Anyway, this is a WP feature that can't be fixed in Relevanssi, so you need to use the post_types query variable to circumvent this. That one is introduced by Relevanssi and won't be touched by WP.

  7. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

  8. joero4ri
    Member
    Posted 2 years ago #

    Using the post_types fixed my problem. Sorry I'm getting back to you so late. Thanks for the quick response.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags