Advertisement
Guest User

Untitled

a guest
Apr 7th, 2015
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. add_shortcode("parentid", "parent_id");
  2. function parent_id($atts) {
  3.         global $wpdb;
  4.  
  5.         $current = $atts["id"];
  6.         // Get current posts parent type
  7.         $parentType = $wpdb->get_var("SELECT  `meta_key` FROM  `wp_postmeta` WHERE  `post_id` ={$current} AND `meta_key` LIKE '%belongs%'");
  8.  
  9.         // Get current posts parentID if project
  10.         $parentID = $wpdb->get_var("SELECT  `meta_value` FROM  `wp_postmeta` WHERE  `post_id` ={$current} AND  `meta_key` =  '{$parentType}'" );
  11.         return trim($parentID);
  12.  
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement