समान कुंजी के साथ म्यूटेंट मेटा कुंजी मान के लिए क्वेरी कैसे करें
$querystr = "
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_key = 'key1'
AND $wpdb->postmeta.meta_value = 'value1'
// why doesn't this work?
AND $wpdb->postmeta.meta_value = 'value2'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
ORDER BY $wpdb->posts.post_date DESC
";
अगला कोड
<?php
$args = array(
'meta_query' => array(
array(
'key' => 'key1',
'value' => 'value1',
'compare' => '='
),
// this array results in no return for both arrays
array(
'key' => 'key1',
'value' => 'value2',
'compare' => '='
)
)
);
$the_query = new WP_Query( $args );
?>
<?php /* Start the Loop */ ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>