Add an Archiving message above the content (instead of in the title)
-
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!
- You must be logged in to reply to this topic.