• Hello all

    I wonder if anyone has any ideas on this. I’ve trying to create an advanced search form on my wordpress site that is able to search both categories and custom field values.

    The form I want to use can be seen at http://interart.madeupdesign.com/advanced-search/

    The medium drop down box is a list of categories and the values attached to those fields are the category ID numbers. The other fields are all custom fields with values stored in the postmeta table. Is there a way to query the database to get the search results with this setup??

    The current query I have, which only searches on category ID is

    <?php
    $pageposts = $wpdb->get_results("SELECT *
    FROM wp_posts, wp_post2cat, wp_postmeta
    WHERE wp_posts.id = wp_post2cat.post_id
    AND wp_postmeta.post_id = wp_posts.id
    AND wp_post2cat.category_ID = '$medium'
    GROUP BY wp_posts.ID
    ORDER BY wp_posts.ID desc");
    ?>

    Where the medium variable is retrieved from the URL. I have to admit I’m now stuck on how to query the postmeta info, let alone use the width and height values to search ranges

    Would I be more sensible to create a couple of extra fields in the posts table? I think this would make the querying a bit easier but I don’t know how to do it… if that’s a better solution I’d be grateful for some help on doing that.

    Thanks in advance.
    Matt

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Advanced searching on custom fields’ is closed to new replies.