Tagged: x
-
AuthorPosts
-
April 16, 2016 at 4:28 am #885510
xtjoeywxParticipantWhat’s the best way to add a Trust Pilot script to the head of my site? I would like to add it to my child theme. Also, I would like to add a certain Trust Pilot widget div code to all pages through my child theme. Also, is there a way to turn it off on certain pages easily if I want to?
<script type="text/javascript" src="//widget.trustpilot.com/bootstrap/v5/tp.widget.sync.bootstrap.min.js"></script><div class="trustpilot-widget" data-locale="en-US" data-template-id="MY-ID" data-businessunit-id="MY-OTHER-ID" data-style-height="130px" data-style-width="100%" data-theme="light" data-stars="4,5"> <a href="https://www.trustpilot.com/review/mysite.com" target="_blank">Trustpilot</a> </div>April 17, 2016 at 12:19 am #886402
ChristianModeratorHey there,
Please see the articles below to learn how to add scripts to WordPress.
http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/
Add Javascript and CSS files to the Head and Footer in WordPress
To add a widget, please see https://community.theme.co/kb/unlimited-sidebars/. To turn off a widget or a sidebar for a page, you would need to choose a page template with no sidebar. Please see https://community.theme.co/kb/page-templates/ for more details about page templates.
Thanks.
April 25, 2016 at 4:03 am #898297
xtjoeywxParticipantI don’t want to add the trust pilot widget to a sidebar or a widget because it spans all the way across a page. It usually right above the footer (see attached image). I would like to add the div code (above) to all of the page templates so that the widget just shows up on the bottom of the page above the footer. Same with the woocommerce product pages. How do I do that using the child theme?
April 25, 2016 at 9:47 am #898718
ThaiModeratorHi There,
Please add the following code under functions.php file locates in child theme:
add_action( 'wp_head', 'x_print_custom_scripts' ); function x_print_custom_scripts(){ ?> <script type="text/javascript" src="//widget.trustpilot.com/bootstrap/v5/tp.widget.sync.bootstrap.min.js"></script> <?php } add_action( 'x_after_view_global__footer-widget-areas', 'x_print_custom_HTML' ); function x_print_custom_HTML(){ ?> <div class="trustpilot-widget" data-locale="en-US" data-template-id="MY-ID" data-businessunit-id="MY-OTHER-ID" data-style-height="130px" data-style-width="100%" data-theme="light" data-stars="4,5"> <a href="https://www.trustpilot.com/review/mysite.com" target="_blank">Trustpilot</a> </div> <?php }Hope it helps 🙂
April 25, 2016 at 3:53 pm #899288
xtjoeywxParticipantThat works but I would like to have it above the widgeted footer area, not inside of it. Above the entire black footer in the white area (between the body and the widgeted footer). Also, I would like to put a different Trust Pilot div code in the same location on the page but on all of the woocommerce product pages.
In other words, there will be one trust pilot widget on all of the posts and pages. Then there will be one on all of the woocommerce product pages.
Code for posts and pages:
<div class="trustpilot-widget" data-locale="en-US" data-template-id="My-ID" data-businessunit-id="My-ID" data-style-height="180px" data-style-width="100%" data-theme="light" data-stars="4,5"> <a href="https://www.trustpilot.com/review/intellibed.com" target="_blank">Trustpilot</a> </div>Code for products:
<div class="trustpilot-widget" data-locale="en-US" data-template-id="My-ID" data-businessunit-id="My-ID" data-style-height="220px" data-style-width="100%" data-theme="light" data-stars="4,5"> <a href="https://www.trustpilot.com/review/intellibed.com" target="_blank">Trustpilot</a> </div>April 26, 2016 at 7:24 am #900194
ZeshanMemberHi there @xtjoeywx,
Thanks for writing back!
In this case, please use this code instead:
add_action( 'wp_head', 'x_print_custom_scripts' ); function x_print_custom_scripts(){ ?> <script type="text/javascript" src="//widget.trustpilot.com/bootstrap/v5/tp.widget.sync.bootstrap.min.js"></script> <?php } add_action( 'x_before_view_global__footer-widget-areas', 'x_print_custom_HTML' ); function x_print_custom_HTML(){ // Code for products if ( x_is_product() ): ?> <div class="trustpilot-widget" data-locale="en-US" data-template-id="My-ID" data-businessunit-id="My-ID" data-style-height="220px" data-style-width="100%" data-theme="light" data-stars="4,5"> <a href="https://www.trustpilot.com/review/intellibed.com" target="_blank">Trustpilot</a> </div> <?php // Code for posts & pages else: ?> <div class="trustpilot-widget" data-locale="en-US" data-template-id="My-ID" data-businessunit-id="My-ID" data-style-height="180px" data-style-width="100%" data-theme="light" data-stars="4,5"> <a href="https://www.trustpilot.com/review/intellibed.com" target="_blank">Trustpilot</a> </div> <?php }Hope this helps. 🙂
Thank you!
April 26, 2016 at 10:50 am #900536
xtjoeywxParticipantThis reply has been marked as private.April 26, 2016 at 10:51 am #900540
xtjoeywxParticipantThis reply has been marked as private.April 27, 2016 at 4:17 am #901722
ThaiModeratorHi There,
Please update the previous code a bit:
add_action( 'wp_head', 'x_print_custom_scripts' ); function x_print_custom_scripts(){ ?> <script type="text/javascript" src="//widget.trustpilot.com/bootstrap/v5/tp.widget.sync.bootstrap.min.js"></script> <?php } add_action( 'x_before_view_global__footer-widget-areas', 'x_print_custom_HTML' ); function x_print_custom_HTML(){ // Code for products if ( x_is_product() ){ ?> <div class="trustpilot-widget" data-locale="en-US" data-template-id="My-ID" data-businessunit-id="My-ID" data-style-height="220px" data-style-width="100%" data-theme="light" data-stars="4,5"> <a href="https://www.trustpilot.com/review/intellibed.com" target="_blank">Trustpilot</a> </div> <?php // Code for posts & pages } else { ?> <div class="trustpilot-widget" data-locale="en-US" data-template-id="My-ID" data-businessunit-id="My-ID" data-style-height="180px" data-style-width="100%" data-theme="light" data-stars="4,5"> <a href="https://www.trustpilot.com/review/intellibed.com" target="_blank">Trustpilot</a> </div> <?php } }Hope it helps 🙂
April 27, 2016 at 9:42 am #902286
xtjoeywxParticipantPerfect! Thank you.
April 27, 2016 at 5:34 pm #903149
FriechModeratorWe’re delighted to assist you with this.
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-885510 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
