Search code examples
phpwordpressadvanced-custom-fields

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.


Solution

  • You will need to create a custom field for the "Post Updated" checkbox and then display the field's value in your page template.

    1. Install the ACF plugin
    2. Create a checkbox field that is added to your Posts
    3. Install the ACF Quick Edit Fields plugin
    4. Display the checkbox field in the Posts lists view as a column
    5. Display the value of the checkbox field in your page template (either single.php, archive.php or category.php) using code similar to below.
    $postUpdated = get_field('post-updated');
    if( $postUpdated && in_array('updated', $postUpdated) ) {
        // Display the "Updated" label.
    }
    

    Check the ACF docs for more info on how to display the label based on checkbox's value.