Switch language

wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren




wp_trash_post [ WordPress Function ]

wp_trash_post ( $post_id = 0 )
Parameter:
  • (int) $post_id Post ID.
Nutzt:
Gibt zurück:
  • (mixed) False on failure
Definiert in:



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;
}
?>

Beispiele [ wp-snippets.com ]

Top Google Suchergebnisse

Mehr ...

0 Nutzerkommentare

Noch keine. Sei der Erste!

Neu hinzufügen ...



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