Post Thumbnails to use lightbox
-
Rather than my post thumbnails loading the single post on click, I wanted the image to load in a lightbox, I have the lightbox plugin installed.
In my PHP template i just have the_post_thumbnail but in my functions file I have the following:
add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 300, 200 ); // 50 pixels wide by 50 pixels tall, resize mode // THIS LINKS THE THUMBNAIL TO THE POST PERMALINK add_filter( 'post_thumbnail_html', 'my_post_image_html', 300, 200 ); function my_post_image_html( $html, $post_id, $post_image_id ) { $html = '<a href="#" rel="lightbox" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>'; return $html; }
As you can see I have amended the URL to remove the_permalink and insert the rel=lightbox attribute.
This does bring up the lightbox but the image does not load, as if it cant find the path to the image.
Could anyone help please?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Post Thumbnails to use lightbox’ is closed to new replies.