How do I search post metadata?
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?
after a few hours messing with the suggestions made in the codex:
$readinglist = $post_meta_cache[‘reading’];
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:
be happy 😉
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:
and is it that I should add this to the functions.php file in the wp-includes directory? Does it matter where?
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.
Someone posted this on another thread:
seems to do the job!
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); ?>
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.
- The topic ‘How do I search post metadata?’ is closed to new replies.