Another substantial update for y’all:

Revamped Admin Page

New CFT Admin Page
The new admin page is built up entirely of shiny 2.7 style boxes. They work just like the ones on your dashboard.

The admin page has been moved to Posts -> CF Taxonomies for easier access. There is also a new feature to add default values.

Enhanced sorting

Version 1.1 introduced an option to display posts with a relevance less than 100%. Now you have an extra option to also adjust the relevance based on the order of the query vars in the URL.

For example, if your URL is http://example.com?foo=xxx&bar=yyy, posts that don’t have bar=yyy, but have foo=xxx will rank higher than those that have bar=yyy but don’t have foo=xxx.

Important bugfix

In earlier version, if you used query_posts() anywhere in the template file that was used by the plugin, you would get all kinds of errors. Not anymore:

Now you can use query_posts() and even have multiple loops on the same page and CFT will only modify the main loop.

Comments (57)

  • stefano says:

    version 1.2 is still compatible with wp 2.6?

  • Nick says:

    Love the new admin page! :)

    How could one detect the presence of meta_relevance? If I have a div that I want to show styled for relevance and only have it appear when relevance returns something, how can I detect that?

    • scribu says:

      You could do something like this:

      $relevance = meta_relevance();
      if ( !empty($relevance) )
        echo '<div class="whatever">' . $relevance . '</div>';
  • Nick says:

    Perfect thanks! :)

  • Nick says:

    Bah – sorry that actually doesn’t work I think because the_relevance() function always returns an echo. Could there be another function that simply does a return instead of echo?

  • brownies says:

    hi there.. nice to know the new release of this plugin. i have a little problem here. when i activate this plugin, it will somehow “crash” (i dont know what to say) with search function, it will give a “no results” in every query in search function. i thought this will fix in the future release, but i dont see in this release. or do i miss something here? together with this plugin i use these: WordPress.com Stats,WP-PageNavi,WP-PostRatings,WP-PostViews,WP-Print and one old plugin “Custom Query String”

    • scribu says:

      Probably “Custom Query String” is the one causing the problmes. Have you tried disabling all plugins and trying the search?

  • Sal says:

    Hi, is it possible to get around the fact that the plugin doesnt display results for posts which have more than one meta_value for one meta_key?

    I’m using a form with method=”get” to search posts by multiple custom fields. So I have a drop down for ‘area’, ‘menu’, and a text box for ‘restaurant’. the ‘menu’meta key has more than one meta value for some posts.

    So, to get all entries the url on form submission is: http://www.mysite.com/?area=&menu=&restaurant= but this only displays posts where one meta value exists for meta key = ‘menu’.

    Anyway to show posts with multiple values for ‘menu’?

    I don’t mind tweaking the code with a little hint. Or is there anyway to remove the “&menu=” part of the URL upon form submission when the default value is selected?

    So the problem is only when nothing is selected for menu. If something IS selected for meta key ‘menu’then the correct posts are displayed even if they have more than one meta value for ‘menu’.

    Thanks for reading.

    • scribu says:

      In query.php, try replacing this line (88):

      $having = ' HAVING COUNT(post_id) = ' . count($this->query_vars);

      with

      $having = ' HAVING COUNT(post_id) >= ' . count($this->query_vars);

      • Sal says:

        sorry for not using REPLY the first time.

        First, thanks for your input. The change you highlighted DOES fix the problem of showing all posts.

        However, prior to this change and with this change I still have an issue that when I do something like this I get the correct results PLUS those posts that have more than one meta value for ‘menu’:

        mysite.com/?area=london&menu=&restaurant= will give all the posts with area = london, BUT ALSO all the posts where ‘menu’has multiple entries and area=something else.

        I’ve confirmed that I have UNCHECKED the Setting for show all posts that don’t match all key value pairs, as I am only looking for results that are a 100% match.

  • Sal says:

    Well, I found one way to get around my problem although I’m not sure it is the best solution.

    I know use a form with method post, and action is a new php redirect file. This redirect file has two conditions, when ‘menu’is NULL and not NULL. When it is NULL, it removes &menu= from the URL giving me all my results including those that have multiple meta values for meta key ‘menu’.

    If there is a better solution, I would like to know.

    Thanks for reading.

  • Sal says:

    Thanks scribu for that SUPER FAST response, I’ll check the change to the condition you mentioned >= and see what happens!!

  • Sal says:

    One more question. Can I please get a usage example for outputing meta_cloud() function in the template? I think I have stupid syntax error somewhere which is making me pull my hair out since I don’t get any out put.

    In addition, are the ‘key’values case sensitive? Since it doesn’t seem to matter when using in the URL but it might here.

    Thanks.

    • scribu says:

      meta_cloud('key=your_key', 'number=100');

      That is equivalent to:

      meta_cloud(array('key' => 'your_key'), array('number' => 100));

      The second set of args is optional and yes, keys are case sensitive in this case.

  • Sal says:

    Hi scribu, how do we sort order query results by a specific meta key value? I assume we can change the parameter on line 103 of query.php:

    function posts_orderby($orderby) {
    return "meta_rank DESC, " . $orderby;
    }

    Will that work? How do I specify orderby “meta value of a certain meta key”? In other words alphabetically by custom field value.

    Thanks for your help as ususal.

    • scribu says:

      I don’t know how you might achieve that through SQL, but it might be easier to sort the posts after they are retrieved, using PHP’s usort():

      // First hook into the <em>found_posts</em> filter
      add_filter('found_posts', 'my_custom_post_order');
       
      function my_custom_post_order($posts) {
        usort($posts, 'my_custom_sort_function');
       
        return $posts;
      }
       
      function my_custom_sort_function($a, $b) {
        // just to show you that $a and $b are post objects
        echo $a-&gt;ID;
       
        // compare keys and values here, 
        // using get_post_meta() or whatever
      }
  • adaptiman says:

    Scribu:

    Please checkout

    http://wordpress.org/support/topic/263013?replies=4

    I can’t get 1.2 to work at all and I’m getting the same bug that is described here.

  • Hello,

    Is this plugin compatible with the new “custom taxonomies” feature available on WordPress 2.8?

    My biggest concern is about some kind of conflict between taxonomies created using the plugin vs. using WP’s native admin panel.

    More info about WP 2.8′s taxonomy here:
    http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28

    • scribu says:

      Yes, it’s fully compatible because it’s completely separate from the native taxonomies: meta taxonomies are stored in wp_postmeta whereas native taxonomies are stored in wp_terms etc.

  • adaptiman says:

    How would I search for multiple values for a field? Can I separate them with commas? for example:

    http://website.com/?key1=value1,value2,value3&key2=value4...

    • scribu says:

      I’m afraid multiple value search is not available yet. If it gets implemented, it will probably be a comma separated list, as you suggested.

  • Ray says:

    Hi scribu,

    I have a usage question.

    Is the string only used on the root?
    Can it be used for categories as well?

    eg.
    http://website.com/category/?foo=bar

  • adaptiman says:

    Is there a way to an AND based search? In other words I want to query posts that have key1=value1 AND key2=value2

  • adaptiman says:

    When is that going to be released (ballpark)?

  • Michael Acosta says:

    Howdy – I am running WP v2.8 and v1.22 of this plugin. When I try to register a taxonomy, I get the following error message:

    Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /var/www/wordpress/wp-content/plugins/custom-field-taxonomies/inc/scb/Options.php on line 60

    Are you seeing this error in any other situations? Is there any additional information that I might be able to provide that might allow you to provide some suggestions?

    Thanks in advance,

    -M

    • AJ Jack says:

      I am using the same versions and getting the same error as Michael Acosta.
      I thought it might have been a clash with another custom field plugin,(Custom Field Template by Hiraoki Miyashita and get custom field values by Scott Reilly) but I deactivated them and still got the error.
      Oh! just saw the note about the development version, so I will try it.

  • Lodewijk Bos says:

    I used version 1.2.2 in WP 2.7 and it worked perfectly. After installing 2.8 everything is gone apart from the settings page. No boxes on the new post or edit.
    HELP?

  • scribu says:

    @Michael Acosta and @Lodewijk Bos:

    Please try the development version (1.3a).

  • Lodewijk Bos says:

    I sincerely apologise for taking up your time. I got confused with a taxonomy plugin. Thank you for your time, I really appreciate it.

    • scribu says:

      That’s alright. It’s easy to get confused:

      Custom Taxonomies, Custom Field Taxonomies, Custom Field Template