I'm looking to pull up an array of posts based on custom field values:
function GetPrimaryLinks($product){
echo '<ul>';
$args = array(
'product' => $product,
'meta_key' => 'primary_link',
'meta_value' => array(
'home',
'obj_handling',
'standalone_doc',
'advantages',
'weaknesses',
'top_comments') );
$primarylinks = get_posts( $args );
foreach ($primarylinks as $post) : setup_postdata($post);
echo '<li><a href="'.the_permalink().'">'.the_title().'</a></li>';
endforeach;
echo '</ul>';
}
Therefore, I can reuse the function on various products to pull up the pages for 'Home', "Obj. Handling", etc. and only use one SQL query each time.
This script obviously doesn't work because it's looking for posts with an array of meta_values, but I'm wondering if there's a way to write the function in one SQL query, rather than breaking up the meta_values into individual queries.