Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为了检查帖子ID是否存在,我这样做:
if ('publish' == get_post_status ($post_id)) { // do something }
但是我如何检查 id 是否与 php 中的不同:
if ($id != $var) { //do stuff }
我在做什么 :
$post_id = get_the_ID(); if ($post_id != 835) { //do stuff }
这是对的吗 ?
那么使用以下任何一种方法都应该适合您。如果当前帖子 ID不是8,则打印出“Not post 8”。如果要打印其他内容,可以添加 else 语句。
<?php $post_id = get_the_ID(); if ($post_id != "8") { echo "Not post 8"; } ?> <?php $post_id = get_the_ID(); if ($post_id != 8) { echo "Not post 8"; } ?>