Link to post images in template with custom function
-
I am trying to use a link in a page template to display the images from a post with a lightbox. I have added the following code to my functions.php:
function portfolio_thumbnail_url($pid){ $image_id = get_post_thumbnail_id($pid); $image_url = wp_get_attachment_image_src($image_id,'screen-shot'); return '$image_url[0]'; }
In my page template the link looks like this:
<a title="<?=$title?>: <?=$desc?>" rel="lightbox[work]" href="<?php print portfolio_thumbnail_url($post->ID) ?>"><?php the_post_thumbnail('project-thumb'); ?></a>
The results right now seem to be only showing one of my two post images and it shows it twice. I’ve been racking my brain on this for a while and any help would be appreciated. It could be the lightbox plugin I’m using (lightbox plus) but I am thinking it is an error in the function I have.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Link to post images in template with custom function’ is closed to new replies.