首页 > 解决方案 > How to display "Post Updated" label in front of post title wordpress

问题描述

I am new here and it's my first post, so please ignore, in case of any mistake. I have some posts published on my website, which is a video episode website. I just want to show a label on the front end saying that the episode has been updated. I want to control it through the Quick edit window by a "Post Updated" checkbox.

I have no idea to do this, please guide me if there is any WordPress plugin or any code or snippet which can solve my problem. Kindly look at this post https://indiandrama.xyz to better understand my situation.

Thanks in advance.

标签: phpwordpressadvanced-custom-fields

解决方案


您需要为“更新后”复选框创建一个自定义字段,然后在您的页面模板中显示该字段的值。

  1. 安装ACF 插件
  2. 创建一个添加到您的帖子的复选框字段
  3. 安装ACF 快速编辑字段插件
  4. 将帖子列表视图中的复选框字段显示为一列
  5. 使用类似于以下的代码在页面模板(或 或)single.php中显示复选框字段的值。archive.phpcategory.php
$postUpdated = get_field('post-updated');
if( $postUpdated && in_array('updated', $postUpdated) ) {
    // Display the "Updated" label.
}

查看ACF 文档以获取有关如何根据复选框的值显示标签的更多信息。


推荐阅读