我有一个循环,它工作得很好,完全符合我的要求。问题是,我需要排除已经标记为使用add_user_meta查看的特定帖子。使用update\\u user\\u meta和值为“1”的帖子id将每个帖子标记为已查看。
$_goal = $_GET[\'goal\'] != \'\' ? $_GET[\'goal\'] : \'\';
$calmargs = array(\'post_type\'=>\'yoga_post\',\'goal\'=>$_goal,\'orderby\'=>\'date\',\'order\'=>\'DESC\',\'posts_per_page\'=>1);
$calm = new WP_Query($calmargs);
if ($calm->have_posts()) {
while($calm->have_posts()) : $calm->the_post(); ?>
<div>
<div>
<a href="https://members.com/?det=<?php echo get_the_ID(); ?>" target="_blank"><?php the_post_thumbnail(); ?></a>
<h4 style="height:70px;padding-top:15px"><a href="https://member.com/?det=<?php echo get_the_ID(); ?>" target="_blank" title="<?php the_title(); ?>"><?php the_title(); ?></a><h4>
<?php
$yogavid = get_the_ID(\'yoga_post\');
$videowatched = get_user_meta($current_user->ID, \'video_viewed_\' . $yogavid, true);
$one = \'1\';
$zero=\'0\';
if ($videowatched != \'1\'){ ?>
<form method="POST" target="_self" action="">
<input type="submit" class="watched-vid" id="<?php echo ($one.$yogavid); ?>" name="<?php echo ($one.$yogavid); ?>" value="Mark as Viewed">
</form>
<?php if(isset($_POST[($one.$yogavid)])){
update_user_meta($current_user->ID,\'video_viewed_\' . $yogavid, \'1\'); ?>
<script>
jQuery(\'#<?php echo ($one.$yogavid); ?>\').attr( \'value\' , \'Viewed\' );
</script>
<?php }
} else { ?>
<form method="POST" target="_self" action="">
<input type="submit" class="watched-vid" id="<?php echo ($zero.$yogavid); ?>" name="<?php echo ($zero.$yogavid); ?>" value="Viewed">
</form>
<?php if(isset($_POST[($zero.$yogavid)])){
update_user_meta($current_user->ID,\'video_viewed_\' . $yogavid, \'0\'); ?>
<script>
jQuery(\'#<?php echo ($zero.$yogavid); ?>\').attr( \'value\' , \'Mark as Viewed\' );
</script>
<?php }
} ?>
<?php
$calmpost = get_the_ID(\'yoga_post\');
add_user_meta($user_id,\'calm_post\', $calmpost, true); ?>
</div>
</div>
<?php
endwhile;
我需要排除键“video\\u viewed\\u”中值为“1”的帖子$约伽维德。我尝试过嵌套循环和pre\\u get\\u帖子,但都是空的。如果您能给我一些建议,我将不胜感激!