• Resolved aviendha75

    (@aviendha75)


    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.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Vova

    (@gn_themes)

    Hey @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

    (@aviendha75)

    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.