I'm trying to make a single page site that will display posts as thumbnails in some part. Then if a thumbnail is clicked, I want all the images contained in this post to be loaded with fancybox while the user is staying on the home.
I'm loading the first image on my template with this <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a>
.
And post images are just created in the editor this way <a href="blabla/image.jpg"><img src="blabla/image.jpg" /></a>
.
When I click the thumbnail, the browser follows the permalink. So I'm stuck with 2 different approaches now.
Loading
the_content
of the post and then hiding all the images BUT the first...Keeping on with
the_post_thumbnail();
and then write something that will find the post ID, and then will display the rest of the attached images.
I'm aiming for the 2nd one, but I'm a very novice WP dev so don't know how to write the "find ID" function... Anyone can help? BTW Fancybox is running OK, I can open images.
the_permalink()
if you are trying to open up an image? Find it's URL using wp_get_attachment_image_src or similar, and echoing out it's URL in the <a> tag. codex.wordpress.org/Function_Reference/…rel="fancybox"
but as GhostToast said, the problem seems to come fromthe_permalink()
since it's already working with img src. I think I have to write a proper query with wp_get_attachment_image_src instead, is that right? I'm still trying to understand how it works...