Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
How to include smoothState.js or any JS library in wordpress theme efficiently

me and a friend web developer tried so many solutions before bothering you here. We humbly ask your help, We also saw that Stack overflow is open for help if we put the tag : smoothState.js. we really need your help, here's our problem :

We tried to include the JS library (or jquery plugin i should say ) in my wordpress theme https://github.com/miguel-perez/smoothState.js#intro

and we followed this article instructions to achieve that : https://webdesign.tutsplus.com/tutorials/how-to-integrate-smoothstatejs-into-a-wordpress-theme--cms-26610

So the steps we followed are : 1- create a child theme 2- copy and paste the jquery.smoothState.js from github repository to main theme --- asset --- js [1]: https://i.stack.imgur.com/CfMGS.jpg here's the screenshot : [enter image description here][1]

3- use the wordpress function to enqueue javascript in function.php of the child theme : The code is like that :

wp_register_script( 'scount', get_template_directory_uri() . '/assets/js/jquery.smoothstate.js' );
wp_enqueue_script( 'jquery-smoothstate-js', 'assets/js/jquery.smoothstate.js', array( 'jquery' ), '0.5.2' );
wp_enqueue_script( 'script-js', 'assets/js/script.js', array( 'jquery', 'jquery-smoothstate-js' ), '1.0.0' );

4- create a script.js in the theme folder ---- asset --- js and we putted this code :

<script type='text/javascript' src='wp-includes/js/jquery/jquery.js'></script>
<script type='text/javascript' src='assets/js/smoothstate.js'></script>
<script type='text/javascript' src='assets/js/script.js'></script>

( function( $ ) {

    $( function() { // Ready

        var settings = { 
            anchors: 'a'
        };

        $( '#page' ).smoothState( settings );
    } );

})( jQuery );

then we added the css found in the article in order to add an animation :

.site-content { -webkit-transition: -webkit-transform .28s, opacity .28s;

-ms-transition: -o-transform .28s, opacity .28s;

-o-transition: -o-transform .28s, opacity .28s;

transition: transform .28s, opacity .28s;

}

Please help us ... and if you do, be as clear as possible, we are two beginners and we need clear instructions without confusion. What is wrong with what we did ? We searched the whole internet on how to add JS library in wordpress and that's all we found. Why it is not working ?

Thank you in advance

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda