Guest User

Untitled

a guest
Oct 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2. $wpquery = new WP_Query('post_type=myposts');
  3. if( $wpquery->have_posts() ) {
  4. while ($wpquery->have_posts()) : $wpquery->the_post();
  5.  
  6. $id = get_the_ID();
  7. //just a test to see can I get post IDs and I get them
  8. echo $id; ?>
  9.  
  10. <a href="<?php echo get_delete_post_link($id); ?>">Delete</a>
  11. <?php endwhile; }
  12. wp_reset_query();?>
  13.  
  14. <a href="">Delete</a>
  15.  
  16. if ( !$post = get_post( $id ) )
  17. return;
  18.  
  19. $post_type_object = get_post_type_object( $post->post_type );
  20. if ( !$post_type_object )
  21. return;
  22.  
  23. if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) )
  24. return;
  25.  
  26. if ( !$post = get_post( $id ) ) {
  27. echo 'could not get post. ';
  28. } else {
  29. echo 'got post. ';
  30. }
  31.  
  32. $post_type_object = get_post_type_object( $post->post_type );
  33. if ( !$post_type_object ){
  34. echo 'could not get post object. ';
  35. } else {
  36. echo 'got post object. ';
  37. }
  38.  
  39. if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) ){
  40. echo 'user does not have proper capability. ';
  41. } else {
  42. echo 'user is ok to delete this post. ';
  43. }
  44.  
  45. if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) )
  46. return;
Add Comment
Please, Sign In to add comment