I have a wordpress blog: http://technosting.com/
On my homepage each post has an image before it, this image is linked to the post. Also when the post is opened the same image is still linked to the post URL. I use a fancybox plugin that makes a gallery of any photo that is linked to its self. For example just look at any of the other images inside the post, excluding the first image of coarse. I would like it so that on the front page the image is linked to the blog post as it is now but when the blog post is opened, I would like the image to link to its self so that the fancybox can be used to view the image. I looked for hours online but am not able to find any solution for this. How can I make this work?
Thanks in advance,
What you want here, is is_single().
Add this in your functions.php
function enqueue_fancybox(){
wp_enqueue_script('my_custom_js', '/path/to/my/custom.js', array('jquery', 'fancybox'));
}
if(is_single(){
add_action('wp_head', 'enqueue_fancybox');
}
Where custom.js
calls the code required to create the fancybox. The code also indicates that it has a dependency on the enqueued scripts jquery
and fancybox
This will ensure it's not fired on the front page, where it's pulling a list of multiple posts, because is_single()
will return false, and the conditional expects true.