I have create a meta box for my posts, that can save one of the three values 0, 1, 2. The value is selected with an select control.
Also I have check my datebase records, and the meta data are stored in database, but I cannot query the meta values.
The code I use to query my posts containing meta values is the following:
$args = array(
'category__in' => array(
22
),
'posts_per_page' => 1,
'meta_query' => array(
array(
'key' => 'postStatus',
'value' => 1,
'compare' => '='
)
)
);
$extremely_important = new WP_Query($args);
while($extremely_important->have_posts())
{
$extremely_important->the_post();
the_title();
}
The excact issue, is that return a post from category 22, but return the latest posts, that is not have the meta value set to 1.
any idea please ?
Here are the data in my postmeta table in SQL Insert statemts:
/*
-- Query: SELECT * FROM wp_postmeta WHERE post_id = 187754
LIMIT 0, 1000
-- Date: 2013-02-14 09:50
*/
INSERT INTO `wp_postmeta` (`meta_id`,`post_id`,`meta_key`,`meta_value`) VALUES (16847,187754,'_edit_last','1');
INSERT INTO `wp_postmeta` (`meta_id`,`post_id`,`meta_key`,`meta_value`) VALUES (16848,187754,'_TIP_protect_images_post','unchecked');
INSERT INTO `wp_postmeta` (`meta_id`,`post_id`,`meta_key`,`meta_value`) VALUES (16849,187754,'_TIP_protect_text_post','unchecked');
INSERT INTO `wp_postmeta` (`meta_id`,`post_id`,`meta_key`,`meta_value`) VALUES (16850,187754,'_thumbnail_id','166897');
INSERT INTO `wp_postmeta` (`meta_id`,`post_id`,`meta_key`,`meta_value`) VALUES (16851,187754,'_fpp_is_scheduled','');
INSERT INTO `wp_postmeta` (`meta_id`,`post_id`,`meta_key`,`meta_value`) VALUES (18502,187754,'_edit_lock','1360791749:1');
INSERT INTO `wp_postmeta` (`meta_id`,`post_id`,`meta_key`,`meta_value`) VALUES (18503,187754,'post_status','extremely_important');
INSERT INTO `wp_postmeta` (`meta_id`,`post_id`,`meta_key`,`meta_value`) VALUES (18504,187754,'postStatus','1');