Tagged: x
-
AuthorPosts
-
December 9, 2016 at 11:31 am #1287565
AlternativeAdventuresParticipantHello,
I have been looking similar topics (insert javascript on a page), but decided to open a new one for the exact thing as I believe it’s popular.
I want to insert a sky scanner widget.
The instructions I follow here: http://business.skyscanner.net/portal/en-GB/Documentation/WidgetsStartbut without success.
Can you help?
Page URL where I want to insert it is https://www.ontherock.es/one-stop-useful-info
All is up to date.
ThanksDecember 9, 2016 at 6:03 pm #1287873
JadeModeratorHi there,
You can add the following scripts in your head section by pasting the following code in your child theme’s functions.php file:
add_action('wp_head', 'custom_scripts'); function custom_scripts() { if(is_single('2697')) { ?> <script type="text/javascript" src="//api.skyscanner.net/api.ashx?key=[WIDGET-KEY]&ssl=true"></script> <?php } }Then add this code in a Raw Content element:
<script type="text/javascript"> skyscanner.load("snippets", "2"); function main() { [WIDGET-SET-UP] }; skyscanner.setOnLoadCallback(main); </script>Please replace [WIDGET-SET-UP] with the specific settings for your widget.
Let us know how this goes!
December 15, 2016 at 5:55 am #1294093
AlternativeAdventuresParticipantHi,
I still can’t make it work.
This is how my functions.php looks like: see the attached file.
And the code in the raw content is:
<script type=”text/javascript” src=”//api.skyscanner.net/api.ashx?key=asaskyscannerwidget”></script>
<script type=”text/javascript”>
skyscanner.load(“snippets”,”2″);
function main(){
var snippet = new skyscanner.snippets.SearchPanelControl();
snippet.setShape(“box400x400”);
snippet.setCulture(“en-GB”);
snippet.setCurrency(“EUR”);
snippet.setMarket(“UK”);
snippet.setDestination(“TENE”, false);
snippet.setColourScheme(“springgreenlight”);
snippet.setProduct(“flights”,”1″);snippet.draw(document.getElementById(“snippet_searchpanel”));
}
skyscanner.setOnLoadCallback(main);
</script>Thank you so much for the help even it doesn’t look is in the scope of your support.
December 15, 2016 at 5:56 am #1294094
AlternativeAdventuresParticipantFunctions.php file
<?php
// =============================================================================
// FUNCTIONS.PHP
// —————————————————————————–
// Overwrite or add your own custom functions to X in this file.
// =============================================================================// =============================================================================
// TABLE OF CONTENTS
// —————————————————————————–
// 01. Enqueue Parent Stylesheet
// 02. Additional Functions
// =============================================================================// Enqueue Parent Stylesheet
// =============================================================================add_filter( ‘x_enqueue_parent_stylesheet’, ‘__return_true’ );
// Additional Functions
// =============================================================================//remove all_in_one_seo_pack urls removed
remove_filter( ‘wp_footer’, ‘onAddScriptsHtmls’);
add_action(‘wp_head’, ‘custom_scripts’);function custom_scripts() {
if(is_single(‘2697’)) {
?>
<script type=”text/javascript” src=”//api.skyscanner.net/api.ashx?key=asaskyscannerwidget&ssl=true”></script><?php }
}December 15, 2016 at 6:32 am #1294137
LelyModeratorHello There,
Please update the code from your child theme’s functions.php file from this:
add_action('wp_head', 'custom_scripts'); function custom_scripts() { if(is_single('2697')) { ?> <script type="text/javascript" src="//api.skyscanner.net/api.ashx?key=[WIDGET-KEY]&ssl=true"></script> <?php } }To this:
add_action('wp_head', 'custom_scripts'); function custom_scripts() { if(is_single('2697')) { ?> <script type="text/javascript" src="//api.skyscanner.net/api.ashx?key=[WIDGET-KEY]&ssl=true"></script> <script type="text/javascript"> skyscanner.load("snippets","2"); function main(){ var snippet = new skyscanner.snippets.SearchPanelControl(); snippet.setShape("box400x400"); snippet.setCulture("en-GB"); snippet.setCurrency("EUR"); snippet.setMarket("UK"); snippet.setDestination("TENE", false); snippet.setColourScheme("springgreenlight"); snippet.setProduct("flights","1"); snippet.draw(document.getElementById("snippet_searchpanel")); } skyscanner.setOnLoadCallback(main); </script> <?php } }Then on the RAW CONTENT element, just add this:
<div id="snippet_searchpanel" style="width: auto; height:auto;"></div>Remember to replace [WIDGET-KEY] with your actual widget key.
Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1287565 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
