• Hello Joshua, thanks for taking over this plugin.

    I’m trying to use this plugin to archive posts, but I want to keep them visible to the public and include an archiving message within the content.

    I’ve found how to keep the posts visible to the public. Is there a way to add a message right above the first paragraph of the content to inform people that the post is archived and may not be relevant anymore? I know there is a label in the title, but I would prefer a more visible message below that I can style.

    I’m not a programmer; I tried something like this, but of course it’s not working (chat GPT and other AI tools can’t do this for me after all ?? ) :

    function display_archived_post_message( $content ) {
    global $post;

    if ( 'archived' === $post->post_status ) {
    $message = __( 'This post is archived and may contain outdated information.', 'archived-post-status' );
    $content = '<div class="archived-post-message">' . $message . '</div>' . $content;
    }

    return $content;
    }
    add_filter( 'the_content', 'display_archived_post_message' );

    Is this something you can help me with and add to the FAQ? I’m also not sure what is used in the code for the “archived” page status. Is it ‘archived’ or something else?

    Thank you for your time!

Viewing 1 replies (of 1 total)
  • Plugin Author Joshua David Nelson

    (@joshuadnelson)

    Hey there! Apologies for the delayed response.

    You’re on the right path here, you can use the content filter or place some code directly in your template or functions file. The status is actually archive following the same naming convention as WordPress core (where it’s publish not published, and trash not trashed).

    Just a word of caution on using that filter – a lot of things go through it, so that message might show up in things like an excerpt view or archives, depending on your theme. You may want to limit your context further, by adding an additional check. For instance, if you only want that message to show up on the Single Post view you could use is_singular() in the if statement:

    if ( is_singular() && 'archive' === $post->post_status ) {

    I hope that helps!

    Joshua

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.