I am attempting to install unslider jquery plugin for my WordPress website. I enter the below code inside my WordPress text editor and I don't get the expected result. I changed $ to jQuery and that didn't fix it either.

<!-- The barebones HTML required for Unslider -->
<div class="banner">
    <ul><li>This is my slider.</li><li>Pretty cool, huh?</li></ul>

<!-- And the relevant JavaScript -->
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="/path/to/unslider.js"></script> <!-- but with the right path! -
<script>$(function() { $('.banner').unslider() })</script>


This is my slider. Pretty cool, huh?

$(function() { $(‘.banner’).unslider() })

  • You have a broken end of comment -> with a \n in between - and the ->, move it up to the end of <-- but with the right path! -->.
    – hcheung
    Apr 17, 2017 at 0:09
  • We don't know if it's pretty cool, it's not working Apr 17, 2017 at 0:15
  • 1
    You can't and shouldn't put arbitrary HTMLin the post/page editor, it gets stripped out by the security filters. There are ways of removing those, but it will make your site much easier to hack. If you need to put scripts and embed codes in the middle of content then use a shortcode
    – Tom J Nowell
    Apr 17, 2017 at 1:09
  • @TomJNowell Where can I put this code? functions.php? Apr 17, 2017 at 2:01

1 Answer 1


You can use this PHP code to output your slider's initiator in your themes footer:

function initiate_unslider () {
    <script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
    <script src="/path/to/unslider.js"></script>
        $(document).ready(function() { 

Also it's safer to add a $(document).ready before initiating your slider, in case some necessary components of your page has not been loaded yet.

  • This breaks my site when added to footer.php or functions.php. Where did you want me to add this? Apr 17, 2017 at 4:10
  • In your functions.php file. Did you open and close the php tags properly? I added the opening and closing tags to the code. BTW, what kind of break? Fatal php error?
    – Johansson
    Apr 17, 2017 at 5:34
  • I didn't open and close the php tags properly. I got a Server 500 error Apr 17, 2017 at 5:40
  • Sorry my bad. I forgot to use the word function. It should work now.
    – Johansson
    Apr 17, 2017 at 5:40
  • I got another serve 500 error. Trying your updated code! Apr 17, 2017 at 5:43

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.