Title: the_ID() inside shortcode
Last modified: March 18, 2019

---

# the_ID() inside shortcode

 *  Resolved [aviendha75](https://wordpress.org/support/users/aviendha75/)
 * (@aviendha75)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/the_id-inside-shortcode/)
 * I want to open a lightbox-popup with Shortcodes Ultimate, but I need to insert
   the post-ID inside the Shortcode with “the_ID();”. This will be used inside an
   archive-php, so each of the shortcodes will need its own id.
 * Here’s my code so far:
 *     ```
       <?php
        $my_shortcode = '[su_lightbox type="inline" src="#THE-ID"]';
        $my_shortcode .= '+ show more';
        $my_shortcode .= '[/su_lightbox]';
        $my_shortcode .= '[su_lightbox_content id="THE-ID"]';
        $my_shortcode .= apply_filters('the_content', get_the_content());
        $my_shortcode .= '[/su_lightbox_content]';
       echo do_shortcode( $my_shortcode );
       ?>
       ```
   
 * Does anyone know a solution for this?
    -  This topic was modified 7 years, 2 months ago by [aviendha75](https://wordpress.org/support/users/aviendha75/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Vova](https://wordpress.org/support/users/gn_themes/)
 * (@gn_themes)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/the_id-inside-shortcode/#post-11331503)
 * Hey [@aviendha75](https://wordpress.org/support/users/aviendha75/),
 * try this:
 *     ```
       <?php
       $my_post_id = get_the_ID();
       $my_shortcode = "[su_lightbox type='inline' src='#{$my_post_id}']";
       $my_shortcode .= '+ show more';
       $my_shortcode .= '[/su_lightbox]';
       $my_shortcode .= "[su_lightbox_content id='#{$my_post_id}']";
       $my_shortcode .= apply_filters('the_content', get_the_content());
       $my_shortcode .= '[/su_lightbox_content]';
       echo do_shortcode( $my_shortcode );
       ?>
       ```
   
 *  Thread Starter [aviendha75](https://wordpress.org/support/users/aviendha75/)
 * (@aviendha75)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/the_id-inside-shortcode/#post-11333975)
 * Yes, that did it!
    Thanks a lot!!!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘the_ID() inside shortcode’ is closed to new replies.

 * ![](https://ps.w.org/shortcodes-ultimate/assets/icon-256x256.gif?rev=2547563)
 * [Shortcodes Ultimate - Content Elements](https://wordpress.org/plugins/shortcodes-ultimate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ultimate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ultimate/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ultimate/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [aviendha75](https://wordpress.org/support/users/aviendha75/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/the_id-inside-shortcode/#post-11333975)
 * Status: resolved