Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1399041
    fervanrijswijk
    Participant

    I have s custom post type and I want to display an image which opens a lightbox.

    add_shortcode( 'show_documents', 'display_documents' );
    
    function display_documents(){
    	$args = array(
    		'post_type' => 'documents',
    		'post_status' => 'publish'
    	);
    
    	$string = '';
    	$query = new WP_Query( $args );
    	if( $query->have_posts() ){
    		while( $query->have_posts() ){
    			$query->the_post();
    			$image = get_field('image');
    			
    			
    			$string .= '<div class="x-column x-sm x-1-5">';
    			$string .= do_shortcode( '[image src="'. $image .'" link="true"]' );
    			$string .= '<span>' . get_the_title() . '</span>';
    			$string .= '</div>';
    			
    		}
    	}
    	do_shortcode('[lightbox]');	
    	wp_reset_query();	
    	return $string;
    }

    no it will display a clickable image, but it will not open in a lightbox but in a black page. What am I doing wrong?

    #1399156
    Rahul
    Moderator

    Hi There,

    Thanks for writing in! Please refer to the thread https://community.theme.co/forums/topic/open-images-in-a-lightbox/ .

    Let us know if this helps.

    Thanks!

    #1405352
    fervanrijswijk
    Participant

    Thanks for the reply! This helped me to fix my problem 🙂

    #1405520
    Joao
    Moderator

    Glad to hear it,

    Cheers

  • <script> jQuery(function($){ $("#no-reply-1399041 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>