所以我直接在Admin Dashboard 在我的网站上,下面我将解释我试图实现的目标以及我遇到的问题。
Here is the code:
add_action(\'admin_head\', \'set_scheduled_today_tag\', 99);
function set_scheduled_today_tag() {
    $query = new WP_Query([
        \'post_type\' => \'wp_events\',
        \'post_status\' => [\'schedule\'],
        \'posts_per_page\' => -1
    ]);
    if ($query->have_posts()):
        while ($query->have_posts()):
            $query->the_post();
            $post_date = get_the_date(\'Y/m/d\', get_the_ID());
            $current_date = date(\'Y/m/d\');
            if ($post_date === $current_date) {
                wp_set_post_terms(get_the_ID(), \'Today\', \'event_tag\', true);
            }
        endwhile;
    endif;
    wp_reset_postdata();
    echo \'<style>
            .event_tag-checked {
                background-color: lightblue!important;
            }
            .event_tag-today {
                background-color: #90EE90!important;
            }
          </style>\';
}
Here is what I\'ve completed:
当发布;“日期”;匹配当前日期,添加一个;“今天”;标记到post标记并更改颜色

Here is the issue:
在这个实现之前,我没有遇到任何问题,但现在当我点击一个特定的帖子时,我会看到一个不同的帖子。
如果我将鼠标悬停在Koe Wetzel帖子上,它会返回帖子ID:6608-该帖子甚至不存在于DB中当我打开帖子时,它会引导我在wp_events 古怪的阿尔·扬科维奇(Al Yankovic)等post\\u类型:不明智的虚荣心之旅的不幸回归Questions:
有人知道我的查询有什么问题吗我是否正确地查询了admin post\\u类型方面的帖子我可以用不同的方式查询帖子吗非常感谢您的帮助!
 
                SO网友:DevSem
                这个问题已经解决了。
add_action(\'admin_head\', \'set_scheduled_today_tag\', 99);
function set_scheduled_today_tag() {
    global $post;
    $args = [
        \'post_type\' => \'wp_events\',
        \'post_status\' => \'any\',
        \'numberposts\' => -1
    ];
    $posts = get_posts($args);
    if ($posts) {
        foreach ($posts as $post) {
            setup_postdata($post);
            $post_date = get_the_date(\'Y/m/d\', get_the_ID());
            date_default_timezone_set(\'America/Chicago\');
            $current_date = date(\'Y/m/d\');
            if ($post_date === $current_date) {
                wp_set_object_terms(get_the_ID(), \'today\', \'event_tag\', true);
            }
        }
    }
    wp_reset_postdata();
    echo \'<style>
            .event_tag-checked {
                background-color: lightblue!important;
            }
            .event_tag-today {
                background-color: #90EE90!important;
            }
          </style>\';
}