Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode("parentid", "parent_id");
- function parent_id($atts) {
- global $wpdb;
- $current = $atts["id"];
- // Get current posts parent type
- $parentType = $wpdb->get_var("SELECT `meta_key` FROM `wp_postmeta` WHERE `post_id` ={$current} AND `meta_key` LIKE '%belongs%'");
- // Get current posts parentID if project
- $parentID = $wpdb->get_var("SELECT `meta_value` FROM `wp_postmeta` WHERE `post_id` ={$current} AND `meta_key` = '{$parentType}'" );
- return trim($parentID);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement