Switch language

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




wp_trash_post [ WordPress Function ]

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



Moves a post or page to the Trash

If trash is disabled, the post or page is permanently deleted.

Source


<?php
function wp_trash_post($post_id 0) {
    if ( !
EMPTY_TRASH_DAYS )
        return 
wp_delete_post($post_idtrue);

    if ( !
$post wp_get_single_post($post_idARRAY_A) )
        return 
$post;

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

    
do_action('wp_trash_post'$post_id);

    
add_post_meta($post_id,'_wp_trash_meta_status'$post['post_status']);
    
add_post_meta($post_id,'_wp_trash_meta_time'time());

    
$post['post_status'] = 'trash';
    
wp_insert_post($post);

    
wp_trash_post_comments($post_id);

    
do_action('trashed_post'$post_id);

    return 
$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