Archived topic
Javascript not displaying in a page
17 replies · Started by Philippe Jourdren on June 15, 2017
Hi, I'm a happy blogger using GP Premium.
I try to put a javascript sequence of that type in a page :
<script language='Javascript' src='https://fr.divelogs.de/mylatestdivebig.php?user=xxxxxx' type='text/javascript'></script>
Unfortunately, nothing is displayed
Have you a clue or a solution ?
Cheers
Hi there,
Where are you adding the code currently?
Try the wp_head hook: https://docs.generatepress.com/article/hooks-overview/
I put this sequence in the content of the page.
You can view it there :
http://www.philjourdren.fr/carnet-de-plongees-en-ligne/
What is the script for? Generally the it needs to go in wp_head hook.
It's for displaying an image showing a dive profile, which is hosted on divelogs.de
WordPress strips javascript out of the editor.
Perhaps something like this will help: https://en-ca.wordpress.org/plugins/shortcoder/
No it doesn't, i've installed shortcoder plugin, created a shortcode with the javascript sequence, but the shortcode doesn't work
So the shortcode doesn't output anything at all when you add it to your content?
It displays the test you see when you go the page : http://www.philjourdren.fr/carnet-de-plongees-en-ligne/
I think I must have done something wrong.
I created a shortcode called "last-dive". In the editor i copied :
<script language='Javascript' src='https://fr.divelogs.de/mylatestdivebig.php?user=lizard2802' type='text/javascript'></script>
And then I saved the shortcode. When I use it, it doesn't work
And you're adding [last-dive] to your content?
Yes !
Ah, the instructions (https://en-ca.wordpress.org/plugins/shortcoder/) say to add it like this:
[sc name="my_shortcode"]
This is just what i did ! It seems just t oreplace the text of the shortcode with the script
I don't understand what's going on !
Probably worth just creating your own shortcode.
add_shortcode( 'last_dive', 'last_dive' );
function last_dive() {
ob_start();
?>
<script language='Javascript' src='https://fr.divelogs.de/mylatestdivebig.php?user=lizard2802' type='text/javascript'></script>
<?php
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
Then use: [last_dive]
Thanks ! Do i insert this portion of code into the CSS ?