WordPress.org

Forums

WP Custom Fields Search
not working for custom post type post search (5 posts)

  1. prabhu.swain91
    Member
    Posted 1 year ago #

    Hello,
    I have a custom post type and there are many custom fields in it.
    I have installed this plugin . working fine in wp-admin.
    i filtered search also to my needs.
    but when i am trying to search on the frontend its always showing 0 results.
    Can i have a solution please ??

    http://wordpress.org/extend/plugins/wp-custom-fields-search/

  2. don benjamin
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    If you are searching for custom post types you will need to add a hidden input to the search form. It should be set up as follows:

    Data Type = Post Type
    Widget = Hidden Constant
    Compare = Equals
    Constant Value = <your-post-type>

    Without this, by default the search will be limited to only posts of type "post". <your-post-type> should be the post type as it is stored in the post_type field in the database.

    If you're not sure what the post_type value is you could change the Compare to "Words In" and leave the Constant Value blank. This is a bit hacky, but will work for now.

  3. SEO Staff
    Member
    Posted 1 year ago #

    Tried as you said above but it doesn't work with my custom post type.
    I am using classipress. Pls see http://www.PuraniCar.com

  4. mfalkvidd
    Member
    Posted 1 year ago #

    I am able to search on all "regular" post fields, but if I set Data Type = Custom field instead, the result always returns no search results.

  5. mfalkvidd
    Member
    Posted 1 year ago #

    In my case, the generated query has
    ORDER BY meta2.meta_value
    which needs to be
    ORDER BY meta102.meta_value

    I got it working by changing line 972 of extra_search_fields.php from
    $order=$this->joiner->sql_order($order,$this->name,$this->index,$value,$this->comparison);
    to
    $order=$this->joiner->sql_order($order,$this->name,100+$this->index,$value,$this->comparison);
    but I am not sure if that is the correct solution.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Custom Fields Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic