Relating Images to Posts Using Tags
-
Hi There,
I am trying to have an images (from my media library) be related to a post based only on tags.
So for instance if I have a post with the title “Summer Day” and an image that I have tagged “summer day” (using the WordPress Media Tags plugin) I would like the tagged image to be displayed beside the main content.
I have inserted the line
<?php print do_shortcode('[mediatag name="summer day" size="thumbnail" number=1]'); ?>
into a custom template and it works perfectly.However I would like for that line to be dynamic so the mediatag name gets automatically filled in with the title of the post. So something like this
<?php echo do_shortcode('[mediatag name="'.single_post_title().'" size="thumbnail" number=1]'); ?>
.This does not seem to be valid however as this gets stripped out of the rendered HTML entirely.
Am I writing this wrong or just going about this the completely wrong way? Any help/advice will be greatly appreciated.
Thank you!
- The topic ‘Relating Images to Posts Using Tags’ is closed to new replies.