Using Shortcode in Post Meta
-
Hello,
I’ve spent the better part of the afternoon trying to make this work, all to no avail! I hope someone will have a pointer for me.
I created a shortcode, which works like a charm if I use it in my post content. However, if I use it in a custom/meta field, it doesn’t parse at all and gets displayed as is.
Any idea what might be going on? And more importantly, how I can resolve it?
Here’s the code for it:
function nsg_shortcode( $atts, $content = null ) { global $wpdb; $querystr = " SELECT $wpdb->posts.post_content, $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->postmeta.meta_value FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->postmeta.meta_key = 'quickdef' AND $wpdb->posts.post_title ='$content' "; $nsgdata = $wpdb->get_row($querystr, ARRAY_A); return $content . "<span class=\"pop\"> ( " . $nsgdata['meta_value'] . ")</span> <span class=\"question\">[<a rel=\"nofollow\" href=\"/?p=" . $nsgdata['ID'] ."\" title=\"" . $nsgdata['meta_value'] . "\">?</a>]</span>"; $wpdb->flush(); } add_shortcode('nsg', 'nsg_shortcode');
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Using Shortcode in Post Meta’ is closed to new replies.