• Hi,

    Great plugin and I have it working fine except for one problem. I have a key in a number of posts that has the option of three values to populate. They are “Yes”, “No” and “Unknown”. When searching for the value “No” the value “Unknown” is returned as well because (I believe) it contains the letters “no”. The search page is here https://musiclibraryreport.com/library-search/search/. Any help is most appreciated.

    Thanks

    Art

Viewing 5 replies - 1 through 5 (of 5 total)
  • It is a little bit complicated but you can resolve the trouble.

    First of all, you need to use the cftsearch shortcode with the format attribute like [cftsearch format=0] not just [cftsearch].

    There are several attributes for the search option. searchType is the type of the search fields. searchValue is the value of the search fields. The most important attribute for you is searchOperator. The default operator of the search SQL is LIKE '%blah%'. So it is impossible to distinguish no and unknown. You can change the operator. If you set = as the value of searchOperator, you can get the results you want. Please be careful that these values must be an array.

    Finally, you need to add the first array element of searchType,searchValue, and searchOperator in the cftsearch format. The first array element number is 1. In the cftsearch format, [keyname] will be converted to the default search field. It is same as [keyname][0]. If you set [keyname][1], the first search array element you set will be loaded.

    It is hard to explain the detail. It is the best way to see the example:

    Template Content: #0

    [keyname]
    type = select
    value = yes # no # unknown
    searchType = array('select');
    searchValue = array('yes # no # unknown');
    searchOperator = array('=');

    [cft] and [cftsearch] Shortcode Format]: #0

    keyname: [keyname][1]

    Please use the latest version of this plugin. Let me know if you have any questions. Thanks.

    Thread Starter artmuns

    (@artmuns)

    Sorry not to get back to you sooner. Still wrestling with this and will let you know when I get a handle on it.

    Thanks for your help!

    Art

    Hi Guys,

    Love this plugin and the instructions seem to assume you know a lot about WP and custom fields… which I did not… at first. Its all still a bit fuzzy, but I did figure a couple things out.

    I got this plugin to work well for setting and displaying art specs about paintings in individual posts, but I couldn’t figure out how to make those specs searchable.

    Here’s what I figured out to do:
    1) Make a page called ‘Advanced Search’:
    2) Put this short code in the content of that page: [cftsearch format=1] (I use a different format for my search than for the admin area when I am editing a post — that one is format=0.)
    3) Add a link to this ‘Advanced Search’ page next to the standard WordPress Search box in my header.

    Now people can search the details with ease or just look for general terms under the regular search. (Sorry I can’t post a link because it is for a site that hasn’t launched yet.)

    I still have this question:

    • Is there a way to get the general WP search function to also acknowledge these custom fields?

    Thanks!

    Rosie

    Ok, here’s what shortcode worked best on the Advanced Art Search page:

    [cftsearch template=0 format=1]

    where format 1 is actually BLANK in my settings. That way I don’t get the bullet before every option.

    I’m still looking for ways to get the regular search to acknowledge these custom fields.

    I explored the insertTag = true attribute, but do not want to do that because it will clutter up my Tag cloud.

    Rosie

    YAY! I’ve found a solution. I added the plugin called ‘Search Everything’ and now my simple search that is up in the header combines pages and posts based on the meta data from the custom fields.

    I’m still keeping my Advanced Search because it makes it easier to find a specific piece of art based on specs.

    Rosie

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Custom Field Template] cftsearch problem’ is closed to new replies.