How to write a javascript in wordpress 4.6?

0

Good afternoon, how can I put a small code in javascript and how it should go on a single wordpress page.

    $(document).ready(function(){
    var es_safari = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    var mediaquery = window.matchMedia("(max-media: 1920px)") ;

        if (es_safari && ) {
            if (mediaquery) {
                var o = document.getElementById('box-context-a1');
                o.style.left = '38.200%';               
                var o2 = document.getElementById('box-context-a2');
                o2.style.left = '38.200%';              
                var o3 = document.getElementById('box-context-a3');
                o3.style.left = '38.200%';
                var o4 = document.getElementById('box-context-b1');
                o4.style.left = '38.200%';
                var o5 = document.getElementById('box-context-b2');
                o5.style.right = '38.200%';
                var o6 = document.getElementById('box-context-c1');
                o6.style.right = '38.200%';
                var o7 = document.getElementById('box-context-c2');
                o7.style.right = '38.200%';
    }
}
    
asked by Tysaic 18.09.2017 в 20:07
source

2 answers

0

Try one of these 3, to see if with your Wordpress version you get:

1. Css-Javascript-Toolbox

2. Simple Custom Css

Also, and if you do not want to use plugins, you can insert it directly on the post / page you want, putting the editor in the text view and inserting the following code:

<script type="text/javascript">
    // ...
    alert("tu código javascript aquí");
    // ...
</script>
    
answered by 18.09.2017 / 23:55
source
0

One of the easiest ways is to use this plugin: link you can enter a code of jquery or js on the page or post you want. Once installed you go to the page in question and below the content of the page you will have inserted a box where you can insert JS.

Greetings

    
answered by 18.09.2017 в 21:05