I am trying to array posts containing the value X within their meta_value. I’ve go this so far:
<?php $pagestack = get_pages( array(
...
'meta_value' => 'X'
) );
echo '<ul>';
foreach ($pagestack as $post){
echo '<li>...</li>';
}
//endforeach;
echo '</ul>';
?>
This shows me all pages that have an exact meta_value of X. But in fact my meta_values hold more information than just the X. So now I want to check the meta_value first if it CONTAINS this certain value. How can I do that. I can’t figure it out myself.
Thanks for your help.
Question is confusing because you mention posts yet your query is
"get_pages"which is for pages, they are not the same.Regardless of either, you can just do a traditional wordpress loop, and then use
get_post_customto return an array of values for 1 field. Also look at the related function in the link.http://codex.wordpress.org/Function_Reference/get_post_custom
Is is also worth noting that using
WP Querygives you a lot more room to work with when using the loop and custom fields as can be seen here,http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters