Pass php dynamic variable to shortcode

I see a few errors in your code…

  1. on the html, there was no quotation in front of variable

  2. on the php you say you were calling the short code [modifycontent] but by your php you should have been using [mc].

All the same, here’s how I would do it:

function modifycontent ($atts, $content = null ) {
    $a = shortcode_atts( 
    array(
         'id' => '1',
        ), 
      $atts );

    return '<a href="#" class="open-popup-1" variable="'.$a['id'].'">Click here</a>';
}
add_shortcode( 'mc-shortcode', 'modifycontent' );

this would use the short code [mc-shortcode] to return:

<a href="#" class="open-popup-1" variable="1">Click here</a>

If you used this for the short code: [mc-shortcode id=’1′]

it would return:

<a href="#" class="open-popup-1" variable="2">Click here</a>

(Notice the variable changes)