0

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

[vr_jsp]
[/vr_jsp]

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.

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

1 Answer 1

1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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