WordPress.org

Ready to get started?Download WordPress

Forums

How do I search post metadata? (8 posts)

  1. logista
    Member
    Posted 9 years ago #

    I need to be able to search the custom fields for my posts. As far as I can tell, there was a hack to do this in an older version of WP, but it's a bit beyond my capabilities to adapt it for WP1.5.

    (I have searched the Codex and the support forum and only found stale info -- perhaps I'm using the wrong terms)

    Is there a plugin or workaround that I can use to do this?

  2. spark
    Member
    Posted 9 years ago #

    after a few hours messing with the suggestions made in the codex:
    $readinglist = $post_meta_cache[256]['reading'];
    get_post_custom()
    get_post_custom_keys()
    get_post_custom_values($key)

    i couldn't make it work , on post loops (and I have some of those)
    finally found somewhere on the funtion.php file something that works:

    echo get_post_meta($post->ID,'data',TRUE);

    be happy ;)

  3. niki
    Member
    Posted 9 years ago #

    I'm in the same situation as logista but, unfortunately, I can't follow spark's suggestion.

    is it just the one line of code that I need:
    echo get_post_meta($post->ID,'data',TRUE);

    and is it that I should add this to the functions.php file in the wp-includes directory? Does it matter where?

  4. Taco
    Member
    Posted 9 years ago #

    I have the same problem. I really need to include the costum field values in searches. I've been searching for an hour now, but can't find any solutions for WP 1.5.

    Anybody?

  5. niki
    Member
    Posted 9 years ago #

    Someone posted this on another thread:

    http://randomfrequency.net/wordpress/search-meta/

    seems to do the job!

  6. 3stripe
    Member
    Posted 9 years ago #

    If you want the one line solution, this works for me, to return one value from a custom field, when used inside The Loop:

    <?php echo get_post_meta($post->ID, 'customfieldname', $single = true); ?>

  7. privatestorm
    Member
    Posted 8 years ago #

    The search meta hack doesn't work with the most updated version of WP (1.5.#) only with 1.5 and below. 3stripe - I don't think that's what people are asking for here. What we are looking for is a plugin that will also SEARCH the postmeta data in addition to the post title and post content not just echo the postmeta info for a certain post.

  8. 3stripe
    Member
    Posted 8 years ago #

    Ah ok my bad. There must be an updated plugin for this out there somewhere?

Topic Closed

This topic has been closed to new replies.

About this Topic