Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_publish_post [ WordPress Function ]

wp_publish_post ( $post_id )
Parameters:
  • (int) $post_id Post ID.
Uses:
Returns:
  • (null)
Defined at:



Publish a post by transitioning the post status.

Source


<?php
function wp_publish_post($post_id) {
    global 
$wpdb;

    
$post get_post($post_id);

    if ( empty(
$post) )
        return;

    if ( 
'publish' == $post->post_status )
        return;

    
$wpdb->update$wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post_id ) );

    
$old_status $post->post_status;
    
$post->post_status 'publish';
    
wp_transition_post_status('publish'$old_status$post);

    
do_action('edit_post'$post_id$post);
    
do_action('save_post'$post_id$post);
    
do_action('wp_insert_post'$post_id$post);
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

0 User Note(s)

None yet. Be the first!

Add New ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics