Switch language

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




wp_untrash_post [ WordPress Function ]

wp_untrash_post ( $post_id = 0 )
Parameters:
  • (int) $post_id Post ID.
Uses:
Returns:
  • (mixed) False on failure
Defined at:



Restores a post or page from the Trash

Source


<?php
function wp_untrash_post($post_id 0) {
    if ( !
$post wp_get_single_post($post_idARRAY_A) )
        return 
$post;

    if ( 
$post['post_status'] != 'trash' )
        return 
false;

    
do_action('untrash_post'$post_id);

    
$post_status get_post_meta($post_id'_wp_trash_meta_status'true);

    
$post['post_status'] = $post_status;

    
delete_post_meta($post_id'_wp_trash_meta_status');
    
delete_post_meta($post_id'_wp_trash_meta_time');

    
wp_insert_post($post);

    
wp_untrash_post_comments($post_id);

    
do_action('untrashed_post'$post_id);

    return 
$post;
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

User discussions [ wordpress.org ]

0 User Note(s)

None yet. Be the first!

Add New ...



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