ap_delete_post_activity( WP_Post|integer $post_id )
Description #
Delete all activities related to a post.
If given post is a question then it delete all activities by column activity_q_id
else by activity_a_id
. More detail about activity delete can be found here @see AnsPress\Activity_Helper::delete()
Parameters #
- $post_idWP_Post | integer (Required) WordPress post object or post ID.
Source #
File: includes/activity.php
function ap_delete_post_activity( $post_id ) { $_post = ap_get_post( $post_id ); // Check if AnsPress posts. if ( ! ap_is_cpt( $_post ) ) { return new WP_Error( 'not_cpt', __( 'Not AnsPress posts', 'anspress-question-answer' ) ); } $where = array(); if ( 'question' === $_post->post_type ) { $where['q_id'] = $_post->ID; } else { $where['a_id'] = $_post->ID; } // Delete all activities by post id. return ap_activity_object()->delete( $where ); }
Expand full source code Collapse full source code View on GitHub: includes/activity.php:55
Add your comment