I am trying to create a shortcode inside a php code widget by calling a custom field, like so:
1. I have a shortcode in my post, with format [flickrgallery setid=”<number>”] — for example:
(This part works and places a Flickr thumbnail grid from that particular set in my post).
2. I have defined a custom field, per_post_widget_content, in this particular post it has value 72157626892022672 (same as above)
3. I am trying to figure out how to use a php code widget to not just output the same as in step #1, i.e. [flickrgallery setid=”72157626892022672″] but to actually process it and display my thumbnails in the widget. So far I have tried:
<?php echo ‘[flickrgallery setid=”‘; echo get_post_meta($post->ID, ‘per_post_widget_content’, true); echo ‘”]’; ?>
However, the best I can get it to do is to output the shortcode inside the widget, but not actually do anything with it.
When I use a plain text widget, however, and just put in the full shortcode, it works (but that won’t let me use the custom field on a per post basis…)
I don’t think eval would do it, since I don’t think shortcodes are actually php code, but at this point I’m lost.
Anyone? I stink at PHP…
- The topic ‘Shortcodes in PHP code widget?’ is closed to new replies.