Forums

Add a variable inside a shortcode? (2 posts)

  1. hyperburst
    Member
    Posted 2 months ago #

    Wondering how it might be possible to use a variable inside of a shortcode.
    I have a function that returns the current category number to a variable ($mycatid) and I would like to "pass" this number into the shortcode of a plugin I have installed "AZINDEX" in place of the "1" shown below. (somehow substitute $mycatid for the number)

    My PHP is pretty limited but I understand that the shortcode is seen as a string. Any ideas how I should approach this problem?

    '<?php $mycatid = getCurrentCatID();
    echo do_shortcode('[az-index id="1"]');?>'

  2. iridiax
    Member
    Posted 2 months ago #

    You could try modifying what's going on in the plugin file itself and leave the shortcode in the post unmodified.

Reply

You must log in to post.

About this Topic