WordPress.org

Ready to get started?Download WordPress

Forums

Advance WP Query Search Filter
Result page sort by meta key doesn't work (2 posts)

  1. Susan Langenes
    Member
    Posted 9 months ago #

    First, thank you for this lovely plugin! I am grateful to you for your work; it has been very helpful on this project.

    One thing I can't seem to figure out. We are using two forms here:
    http://stage.oregonfirst.com/search-agents/

    One is for string search (the one on the left with the label "Name includes") and the other for three dropdown filters (language and specialty are taxonomies, and office is custom meta field). I have both forms set to use meta key "last_name" as value for sorting.

    Also, I am redirecting searches performed from these referrers to a custom search template. Other searches performed from elsewhere on the site go to a default search template.

    When a search is performed from the string search form, results are indeed displayed in ASC order by meta value 'last_name'. However, this is not the case for the other search form; I've tried orderby various meta fields and always the result is default date value (posted-on date).

    I have tried customizing the query on the search template itself, but every variation of customized query (wp_query and query_posts) seems to override the search query and gives me all the posts. I am able to echo the 'last_name' meta value correctly on the search results loop, so it appears that that meta key is alive and present in the database.

    Any thoughts?

    http://wordpress.org/plugins/advance-wp-query-search-filter/

  2. TC.K
    Member
    Plugin Author

    Posted 9 months ago #

    Weird, can't tell the reason why is this happened. Maybe it is because of conflict with other plugin.

    Unless you give me the wp_query object on the search query, other wise it is hard to tell what is going wrong.
    To get the wp_query object, simply print it in your custom search template, before the loop.
    Eg:

    global $wp_query;
    print_r($wp_query);
    
    if($post->have_post){.....

Reply

You must log in to post.

About this Plugin

About this Topic