WordPress PHP – Enabling Lightbox Support for Featured Image aka Post Thumbnails

  • WordPress does not support a lightbox (image popup) feature for its Featured Images (or Post Thumbnails) by default.

    WP Featured Images are the images that are chosen as the representative images for Posts, Pages or Custom Post Types. The display of these images is up to the theme.

    On the one hand, most of the themes, like mine, do not support a lightbox for WP featured images out of the box. On the other hand, installing a lightbox plugin doesn’t bring a solution either. All available WP lightbox plugins do not support Featured Images. They do popup images inside a post, but not the Post Thumbnail. For example, I bought FooBox Lightbox-plugin and the author is not willing to help to make the featured images work with its lightbox plugin. He refers to the theme author, and the theme author simply states that its not a theme feature.

    So, I’m searching for help here to make this work. The starting point is to make this code-snippet work with my theme. I tried that snippet, but could not make it work. In my theme, the single.php generates the featured images with this code:

    <?php } ?>
    <?php $mvp_featured_img = get_option('mvp_featured_img'); if ($mvp_featured_img == "true") { ?>
    <?php $mvp_show_hide = get_post_meta($post->ID, "mvp_featured_image", true); if ($mvp_show_hide !== "hide") { ?>
        <?php global $post; $mvp_post_temp = get_post_meta($post->ID, "mvp_post_template", true); if ( $mvp_post_temp == "temp3" || $mvp_post_temp == "temp4" ){ ?>
            <?php if(get_post_meta($post->ID, "mvp_video_embed", true)) { ?>
                
    ID, "mvp_video_embed", true)); ?>
    <!--video-embed--> <?php } else { ?> <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?> <div id="post-feat-img" class="left relative" itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> <?php the_post_thumbnail(''); ?> <?php $thumb_id = get_post_thumbnail_id(); $mvp_thumb_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true); $mvp_thumb_url = $mvp_thumb_array[0]; $mvp_thumb_width = $mvp_thumb_array[1]; $mvp_thumb_height = $mvp_thumb_array[2]; ?> <meta itemprop="url" content="<?php echo $mvp_thumb_url ?>"> <meta itemprop="width" content="<?php echo $mvp_thumb_width ?>"> <meta itemprop="height" content="<?php echo $mvp_thumb_height ?>"> <div class="post-feat-text"> <?php if ( has_excerpt() ) { ?> <span class="post-excerpt left"><?php the_excerpt(); ?></span> <?php } ?> <?php global $post; if(get_post_meta($post->ID, "mvp_photo_credit", true)): ?> <span class="feat-caption"><?php echo wp_kses_post(get_post_meta($post->ID, "mvp_photo_credit", true)); ?></span> <?php endif; ?>

    Thank you for your effort.

  • That site is not on WordPress.COM servers and you cannot get support for it here. You are posting to the wrong support forum.

    WordPress.COM and WordPress.ORG are completely separate and have different username accounts, logins, passwords support docs and support forums, and many people get confused about the two.

    The wordpress.ORG login link is here https://login.wordpress.org/ If you do not have an account yet then click Create an account https://login.wordpress.org/register/ and if you have lost an account password click Lost password? https://login.wordpress.org/lostpassword/

    This is wordpress.COM support. We provide support only for wordpress.COM hosted sites. Our support docs do not apply to
    (1) local installs of wordpress.ORG software on your own server or
    (2) wordpress.ORG software installs on paid hosting, and we do not provide support for them at wordpress.COM.

    Also, note that we do not provide Jetpack support https://jetpack.com/support/ for sites linked to wordpress.COM accounts with the Jetpack plugin so they display on the My Sites wordpress.com account page.

    Some Jetpack solutions are here http://jetpack.com/support/

    Others are in the Jetpack support forum at WordPress.org
    http://wordpress.org/support/plugin/jetpack

    However, if help cannot be found at either one then they can file a Jetpack support ticket here > http://en.support.wordpress.com/contact/?jetpack=needs-service

    WordPress.COM and WordPress.ORG are completely separate and have different username accounts, logins, features, run different versions of some themes with the same names, and have separate support documentation and separate support forums. Read the differences here http://en.support.wordpress.com/com-vs-org/

    WordPress.org support docs are at https://codex.wordpress.org/Main_Page
    See also https://apps.wordpress.org/support/ for app support.

  • Sorry, I didn’t know…

  • No problem and best wishes.

  • The topic ‘WordPress PHP – Enabling Lightbox Support for Featured Image aka Post Thumbnails’ is closed to new replies.