Title: Adding shortcode to php page
Last modified: August 31, 2016

---

# Adding shortcode to php page

 *  [kikib](https://wordpress.org/support/users/kikib/)
 * (@kikib)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/adding-shortcode-to-php-page/)
 * I wanted to know how to add the shortcode to php page so that when one click 
   on a post, a lightbox will show up with post content and you can go back and 
   forth to next post in the lightbox…
 * This is my actual post loop in a page
 *     ```
       <?php if ( $the_query->have_posts() ) : ?>
       <?php
       // the loop
       while ( $the_query->have_posts() ) : $the_query->the_post();
       ?>
       <div class="proyectpost">
                   <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
   
                   <div class="innerpost">
                   <a href="<?php the_permalink(); ?>" title="Permanent Link to <?php the_title_attribute(); ?>">
                   <?php
               	// Get post meta that is already set
               	$custom_values = get_post_meta($post->ID, 'en_proceso_class', true);
           		?>
                    <div class="postthumbnail <?php echo $custom_values; ?>">
                   <?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
       	$image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'full' );
            echo '<img src="' . $image_src[0]  . '" width="100%"  />';
       	} ?>
           		</div>
                   <div class="posttitle">
       		<h2><?php the_title(); ?></h2>
               <span><?php echo get_post_meta($post->ID, 'location', true); ?></span>
       			</div><!-- .entry-header -->
        			</a>
       </div>
       </article><!-- #post-## -->
       </div>
       <?php endwhile; ?>
       ```
   
 * [https://wordpress.org/plugins/wp-colorbox/](https://wordpress.org/plugins/wp-colorbox/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Noor Alam](https://wordpress.org/support/users/naa986/)
 * (@naa986)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/adding-shortcode-to-php-page/#post-7076253)
 * Hi, I believe you will need to pass it through the `do_shortcode` function:
 * [https://developer.wordpress.org/reference/functions/do_shortcode/](https://developer.wordpress.org/reference/functions/do_shortcode/)

Viewing 1 replies (of 1 total)

The topic ‘Adding shortcode to php page’ is closed to new replies.

 * ![](https://ps.w.org/wp-colorbox/assets/icon-128x128.png?rev=2610062)
 * [WP Colorbox](https://wordpress.org/plugins/wp-colorbox/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-colorbox/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-colorbox/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-colorbox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-colorbox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-colorbox/reviews/)

## Tags

 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 1 reply
 * 2 participants
 * Last reply from: [Noor Alam](https://wordpress.org/support/users/naa986/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/adding-shortcode-to-php-page/#post-7076253)
 * Status: not resolved