I am using the jscrollpane plugin on WordPress along with the advanced custom fields plugin. The jscrollpane plugin uses the following shortcodes:


I have two different custom fields that I need to put between their own set of the above shortcodes which are:

<?php the_field('first_content_block'); ?>
<?php the_field('second_content_block'); ?>

I understand you can use the below code to do this but I am a bit stuck on what to use to output the custom field between the two shortcodes.

<?php echo do_shortcode('[vr_jsp]CONTENT HERE[/vr_jsp]'); ?>

Just to clarify I need the custom field (first_content_block) displayed where 'CONTENT HERE' is.

  • get_field – Milo Jul 17 '14 at 20:58
  • Could you show me a working example using the code provided? Sorry to be awkward – BHWD Jul 17 '14 at 21:01

Use get_field instead of the_field. That way you can assign it to a varilable.

$first_comment = get_field('first_content_block');
$second_comment = get_field('second_content_block');

echo do_shortcode("[vr_jsp] $first_comment, $second_comment [/vr_jsp]");

I haven't tried it, but see if that works.

  • Perfect! makes more sense now. Thank you for the easy to understand explnation! – BHWD Jul 17 '14 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.