I got questions from WordPress users how to change page status from ‘published’ to ‘pending for review’ automatically in case its author changed it. Its possible with little piece of code in your theme functions.php file and the same little user capabilities manipulation. You can look how it works on the video by this link or scrolling to the end of this post. So it seems, that problem is resolved. No. WordPress 2011 theme (and possibly others) is written such way, that page (with all changed content) is shown in any status, including ‘draft’. You just should know its link. Make little experiment. Create new page and save its draft. Then type in the browser URL to this page. Do you see it? Yes, me too.
How to change this WordPress behavior?
We need to update the ‘page.php’ template file from the 2011 (Twenty Eleven) theme package.
Compare its content. Before change:
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?phpwhile( have_posts()): the_post();?><?php get_template_part('content','page');?><?php comments_template('',true);?><?phpendwhile;// end of the loop. ?></div><!--#content -->
</div><!--#primary -->
<?php get_footer();?>
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?phpwhile( have_posts()): the_post();?><?phpif($post->post_status!='publish'){?>
<div class="entry-content" style="margin:20px;">
This page content is under review. See you later
</div>
<?php}else{?><?php get_template_part('content','page');?><?php comments_template('',true);?><?php}?><?phpendwhile;// end of the loop. ?></div><!--#content -->
</div><!--#primary -->
<?php get_footer();?>
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php
if ($post->post_status!='publish') {
?>
<div class="entry-content" style="margin:20px;">
This page content is under review. See you later
</div>
<?php
} else {
?>
<?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?>
<?php
}
?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Yes, I added check for page status into the main LOOP. If page is not in the ‘Published’ state then user will see message ‘page content is under review’, but will not see the updated content untill it will be reviewed by site Editor or Administrator.
How to change post status from ‘published’ to ‘pending’ after it was changed:
This entry was posted
on Saturday, January 28th, 2012 at 09:18 and is filed under WordPress.
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.