How to get the all post_id where delete post? Wordpress
<p>I am making a function in a plugin and the function will delete the database row when the post move to the trash bin. However, I cannot get the post_id using <code>get_posts()</code>.</p>

<p>Here is my code:</p>

<pre><code>function delete_condition($post)
{
    global $wpdb;

        $allposts = get_posts(array(
        'numberposts' =&gt; -1,
        'category' =&gt; 0, 'orderby' =&gt; 'date',
        'order' =&gt; 'DESC', 'include' =&gt; array(),
        'exclude' =&gt; array(), 'meta_key' =&gt; '',
        'meta_value' =&gt;'', 'post_type' =&gt; 'job',
        'suppress_filters' =&gt; true));

        foreach( $allposts as $postinfo ) {
            $wpdb-&gt;delete('rule', array('post_id' =&gt; $postinfo));
        }

}
add_action('wp_trash_post', 'delete_condition', 10, 1);
</code></pre>

<p>thanks</p>