Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. function manage_mytype_columns( $column, $post_id ) {
  2. global $post;
  3. $pp_id = get_post($post_id)->post_parent; /*The post parent id is stored also as post meta, so I could also use $pp_id = get_post_meta($post_id, 'post_parent', true) ); */
  4. if ( empty( $pp_id ) ) {
  5. echo __( 'No post parent' );}
  6. else {
  7. $pp_title = get_post($pp_id)->post_title;
  8. echo $pp_title; }
  9. }
  10. add_action( 'manage_mytype_posts_custom_column', 'manage_mytype_columns', 10, 2 );
  11.  
  12. function manage_mytype_columns( $column, $post_id ) {
  13. global $post;
  14. $pp_id = get_post($post_id)->post_parent; /*The post parent id is stored also as post meta, so I could also use $pp_id = get_post_meta($post_id, 'post_parent', true) ); */
  15. if ( empty( $pp_id ) ) {
  16. echo __( 'No post parent' );}
  17. else {
  18. $pp_title = get_post($pp_id)->post_title;
  19. $pp_url = add_query_arg(array('post_type' => $post->post_type, 'post_parent' => $pp_id), 'edit.php');
  20. echo '<a href="'.$pp_url.'">'.$pp_title.'</a>'; }
  21. }
  22. add_action( 'manage_mytype_posts_custom_column', 'manage_mytype_columns', 10, 2 );
  23.  
  24. function make_post_parent_public_qv() {
  25. if ( is_admin() )
  26. $GLOBALS['wp']->add_query_var( 'post_parent' );
  27. }
  28. add_action( 'init', 'make_post_parent_public_qv' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement