Is it possible to take the blue publish button in back end of the wordpress and place it in the frontend near the post in my index.php. I need a way to publish the pending article without going to dashboard and only admin can see the publish button?

'post_type'         => 'post',
'post_status'       => 'pending',
'order'                 => 'ASC',
'caller_get_posts'  =>1,
'paged'         =>$paged,

Thank You all in advance for help :D

1 Answer 1


First create a function that will print the publish button :

//function to print publish button
function show_publish_button(){
    Global $post;
    //only print fi admin
    if (current_user_can('manage_options')){
        echo '<form name="front_end_publish" method="POST" action="">
                <input type="hidden" name="pid" id="pid" value="'.$post->ID.'">
                <input type="hidden" name="FE_PUBLISH" id="FE_PUBLISH" value="FE_PUBLISH">
                <input type="submit" name="submit" id="submit" value="Publish">

Next create a function to change the post status:

//function to update post status
function change_post_status($post_id,$status){
    $current_post = get_post( $post_id, 'ARRAY_A' );
    $current_post['post_status'] = $status;

Then make sure to catch the submit of the button:

if (isset($_POST['FE_PUBLISH']) && $_POST['FE_PUBLISH'] == 'FE_PUBLISH'){
    if (isset($_POST['pid']) && !empty($_POST['pid'])){

Now all of the above code can go in your theme's functions.php file and all you have to do is add show_publish_button(); in your loop of pending posts after each post.

  • Glad i could help.
    – Bainternet
    Commented May 21, 2011 at 18:41
  • Is it possible to have a different name on the buttom? Like submit instaead of publish..
    – user7790
    Commented Aug 10, 2011 at 12:29
  • Of course just change the 'value' of the submit button. Commented Sep 12, 2011 at 21:21
  • Sorry for reviving this old topic @Bainternet but using this code on a test I'm doing is taking me to the wordpress error page "Are you sure you want to do this? Please try again". The post is actually published but it's going to that page for some reason. I'm using Membership plugin and 'manage_options' is active on that user role. Thanks.
    – Jaypee
    Commented Jan 25, 2014 at 18:47
  • @Bainternet sorry the plugin I'm using is Members not Membership.
    – Jaypee
    Commented Jan 25, 2014 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.