单击后,我想将wp\\u查询中的posts元值更新为其他值。我基本上是在做一个通知气泡(比如stackoverflow)。
wp_query
对于元值为“未读”的帖子数量,在登录用户的显示名称上显示计数气泡-工作单击通知时,隐藏气泡并仅使用ajax更改中帖子的元值wp_query
从“未读”到“已读”,这样只有当有一篇新帖子的元值为“未读”时,计数才可见——如何
我看过ajax-like和vote教程,它们一次处理一个帖子。我需要下面的工作,为所有返回的职位从查询和更改在同一时间。add_shortcode(\'notify\', \'notify_member\'); function notify_member() { global $current_user; get_currentuserinfo(); $userid = $current_user->ID; $args = array( \'posts_per_page\' => \'-1\', \'post_type\' => \'answer\', \'post_status\' => \'publish\', \'author__not_in\' => $userid, //exclude user posts \'meta_query\' => array( \'relation\' => \'AND\', array( \'key\' => \'question_owner_id\' \'value\' => $userid, //only show posts for the user \'compare\' => \'=\' ), array( \'key\' => \'_read_answer\' \'value\' => \'unread\', //only show unread posts \'compare\' => \'=\' ), ) ); $questions = new WP_Query( $args ); $html = \'\'; $html .= \'<a href="#" class="count">\'.$questions->found_posts.\'</a>\'; //total count return $html; }
我没有主意,欢迎任何方向。谢谢P、 我不是一个程序员,所以请解释一下。if( $questions->have_posts() ) { while ( $questions->have_posts() ) { $questions->the_post(); update_post_meta( $post->ID, \'_read_answer\', \'read\' ); } }