• Resolved titchpitch

    (@titchpitch)


    Hi,

    I am trying to use a custom shortcode (the groups plugin) to show some specific content in the image description but I cannot get shortcodes to work.

    Anyone had any luck with this or no how to do?

    I am trying to add into the nextgen gallery download template.

    this is the code ive tried:
    <?php echo do_shortcode( "$image->description" ) ?>

    part of this wider code:
    <label><div class="tooltip"><span class="fa-stack fa-lg priceicon"><i class="fa fa-circle fa-stack-2x priceiconbottom" ></i><i class="fa fa-dollar fa-inverse fa-stack-1x priceicontop" ></i></span><span class="tooltiptext"><?php echo do_shortcode( "$image->description" ) ?></span></div><a href="<?php echo $image->imageURL ?>" download><i class="fa fa-download singleimgdownload"></i></a><input type="checkbox" name="pid[]" class="imagecheckbox" value="<?php echo $image->pid ?>" /></label>

    Thanks

    • This topic was modified 8 years, 4 months ago by titchpitch.
    • This topic was modified 8 years, 4 months ago by titchpitch.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Imagely

    (@imagely)

    @titchpitch – The do_shortcode() function requires the actual shortcode so it can be parsed and rendered; it does not take a variable as is.

    Please see https://developer.wordpress.org/reference/functions/do_shortcode/

    Thanks!

    – Cais.

    Thread Starter titchpitch

    (@titchpitch)

    Hi Cais

    Thanks for replying.

    I cant figure out how to parse or render the variable. (even if i put in a shortcode to test instead of a $variable it still prints the string)

    Any ideas how I can either get the variable (aka description) parsed, or to natively allow shortcodes to be rendered within the description itself?

    Thanks 🙂

    Plugin Contributor Imagely

    (@imagely)

    @titchpitch – Parsing a shortcode within a shortcode within do_shortcode() is getting beyond the scope of support for our plugin specifically.

    I would suggest looking at how one might parse the “description” shortcode and then add that as needed to an appropriate parameter (if possible).

    Thanks!

    – Cais.

    Thread Starter titchpitch

    (@titchpitch)

    Thought id leave an update on what I ended up doing.

    I decided to turn the description box into an array in a custom template determining the split using a commar.

    $pricearray = explode(',', $image->description);

    and then used a switch statement to display the right part of the array:

    switch ($userCountry) {
    case "UK":
    	$desc = '£' . $pricearray[0];
    	break;	
    case "Singapore":
    	$desc = 'S$' . $pricearray[1];
    	break;
    case "US":
    	$desc = 'US$' . $pricearray[2];
    	break;
    default;
    	$desc = 'Unavailable';

    finally adding this into title tag:
    <?php esc_attr($desc) ?>

    Maybe this will help someone in the future as possible way to go. Could also use this method of creating an array to make a kind of additional field.

    • This reply was modified 8 years, 3 months ago by titchpitch.
    • This reply was modified 8 years, 3 months ago by titchpitch.
    • This reply was modified 8 years, 3 months ago by titchpitch.
    Plugin Contributor Imagely

    (@imagely)

    @titchpitch – Thanks for sharing!

    – Cais.

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

The topic ‘Using shortcodes within nextgen description’ is closed to new replies.