Home Forums Front-end Issues LightBox images in custom content field


LightBox images in custom content field

  • Hey guys. I have a weird issue here:

    I’m trying to get Gallerys or images i posted in a custom content field to open with a lightbox. It works only for the default content box in the post. The one i created with custom fields doesn’t have the required rel=”lightbox” in its anchor tag.

    How do i add this functionality?

    You can check out an example here:

    [link offline]

    (i know the code is very messy, but it’s still in development)

  • Hi Flowbob,

    Did you try using something like this in your custom theme page, I used fancybox:

    <a class="fancybox" rel="group" href="<?php the_field('name_custom_field'); ?>"><img src="<?php the_field('name_custom_field'); ?>" alt="<?php the_title(); ?>"/></a>

  • The problem is that i’m not only getting image URLs, i’ve got a field with a WYSIWYG editor which gives me all kinds of content, so i can’t hardcode it in my template :/

  • Hi @flowbob

    It is most likely that you have a plugin which is adding the lightbox effect to WYSIWYG galleries. Is this correct?

    if so, all you will need to do is pass the ACF value through the the_content filter – this is how a plugin would modify the_content value.

    $wysiwyg = get_field('field_name', false, false);
    echo apply_filters('the_content', $wysiwyg);

    Please note the extra false, false parameters are to prevent ACF from formatting the value because the_content will also do this.


  • I dont really understand what it does, but this seems to solve the issue 😉
    Thanks Elliot, You’re awesome!

    Am i right that it kind of marks the field as a “the_content” output for plugins i installed?

  • Hi @flowbob

    Kind of, you can read more about this filter on the WP codex.


  • hi
    thank you for this suggestion, but it doesn´t work for me

    <div class="entry-content">
        		<?php the_content(); ?>
    			wp_link_pages( array(
    				'before' => '<div class="page-links">' . __( 'Pages:', 'pictorico' ),
    				'after'  => '</div>',
    			) );
            <?php if(get_field('spalten')): ?>
              <?php while(has_sub_field('spalten')): ?>
              <div class="columns">
              <div class="col-left"><?php 
    		  $wysiwyg = the_sub_field('linke_spalte', false, false); 
    		  echo apply_filters('the_content', $wysiwyg);
              <div class="col-right"><?php 
    		  $wysiwyg = the_sub_field('rechte_spalte', false, false); 
    		  echo apply_filters('the_content', $wysiwyg);
              <?php endwhile; ?>
              <?php endif; ?>
    	</div><!-- .entry-content -->
    I´m using a repeater field, are ther any other options?
    Thank you very much

  • This reply has been marked as private.
  • @michaeldegraaf This fix problem for me 🙂 Thank you!

  • Hi @elliot, this solution didn’t work in my situation, unfortunately.

        $content = get_field('wysiwyg', false, false);
        echo apply_filters('the_content', $content);

    It destroys the output of the wysiwyg, displaying nothing.

    I have the plugin Simple Lightbox installed, which I want to use for the gallery’s lightbox.

    Previously, I was using:


    To output the wysiwyg normally.

    Help appreciated.

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘LightBox images in custom content field’ is closed to new replies.