WordPress.org

Ready to get started?Download WordPress

Forums

Deleting a post programmatically - relationships? (3 posts)

  1. Blutarsky
    Member
    Posted 4 years ago #

    I was wondering if when a

    wp_delete_post

    function is invoked from code, will WordPress delete automatically related items and will automatically decrease tags counters...

  2. MichaelH
    Member
    Posted 4 years ago #

    It should.

  3. Blutarsky
    Member
    Posted 4 years ago #

    Humm.... I have found a code sample like this:

    $custom_field_keys = get_post_custom_keys($postid);
      foreach ( $custom_field_keys as  $key => $value ) {
                $valuet = trim($value);
                if ( '_' != $valuet{0} ){
                     delete_post_meta($postid, $key, '');
                }
      }
      $result = wp_delete_post($postid);

    The code above deletes programmatically custom fields then it deletes the post...

Topic Closed

This topic has been closed to new replies.

About this Topic