Switch language
wpseek on Twitter


A WordPress-centric search engine for devs and theme authors




wp_publish_post [ ]

wp_publish_post ( $post )
Parameters:
  • (mixed) $post Post ID or object.
Uses:
Defined at:
Codex



Publish a post by transitioning the post status.

Source

function wp_publish_post( $post ) {
	global $wpdb;

	if ( ! $post = get_post( $post ) )
		return;

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

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

	clean_post_cache( $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 ...