Hi Minesh,
Let me try to clarify.
We have set up a website listing several restaurants. Visitors can leave a review for each restaurant.
We installed a plugin (Rich Reviews by Starfish) to have this functionality.
To add the Rich review, we simply add a shortcode to the content template.
Everything is working fine so far.
The plugin also adds schema.org data, but since the rich review section is merely a small part of the page, the restaurants address, phone number, etc... are not inside the div that has the itemprop 'LocalBusiness' (hidden link).
Therfor, I want to append them (after the DOM has loaded) using jQuery.
To achieve this, I have to use a custom field in the content template's JS editor.
This is the script I'm using for the moment:
jQuery(document).ready(function(){
jQuery('[itemprop="address"]').append('<span itemprop="streetAddress">[tb-dynamic provider="__current_post" post="current" source="toolset_custom_field|field-group-for-restaurants" field="adres" force-string="first" ]</span>');
})
This is how the DOM looks after script execution:
<div itemscope="" itemtype="hidden link">
<span itemprop="name" style="display: none;">A'Sur</span>
<a itemprop="image" href="hidden link"></a>
<div itemprop="address" itemscope="" itemtype="hidden link" style="display: none;">
<span itemprop="streetAddress">
[tb-dynamic provider="__current_post" post="current" source="toolset_custom_field|field-group-for-restaurants" field="adres" force-string="first" ]
</span>
</div>...
Instead of the actual address, the shortcode is rendered.
So my question.
Is it possible to use dynamic content in the content template's JS editor?
How can I achieve this?
If you want to check a restaurant listing, you can check this page: hidden link
I've added a screenshot to clarify the JS editor part in the content template as well.