Excellent Programming Tricks

WordPress Theme Development | POST related functions


  1. Reference help: https://codex.wordpress.org 
  2. get_posts( array $args = null )
    1. Return list of latest posts [object]
    2. Shows posts matching principle.
  3. get_post ( int|WP_Post|null $post = null, string $output = OBJECT, string $filter = 'raw' )
    1. Post ID returns Post date or object
  4. wp_delete_post(int $postid, bool $force_delete = false )
    1. Permanently delete post/page based in post ID.
    2. Works when force_delete true, what ever the post is in trash, draft, private or public. 
    3. Equivalent Code
      global $wpdb;
      $wpdb->query( 'DELETE FROM wp_posts WHERE post_type = "abc" ' );
      $wpdb->query( 'DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT id FORM wp_posts)' );
      $wpdb->query( 'DELETE FROM wp_term_relationships WHERE object_id NOT IN (SELECT id FROM wp_posts)' );
  5.   

No comments:

Post a Comment


Authentic аnd Excellent

Website

HTML Template

Wordpress Theme

Database applications

OR

Application services?

Excellent Programming Tricks (EPT) || Iftekhar-IT || We develops the Web applications and the WordPress templates. || Excellent Programming Tricks (EPT)

© 2020 Blogger Theme by Iftekhar IT || Excellent Programming Tricks

Execllent Programming Tricks. Powered by Blogger.