R
R
redd_i2018-05-22 15:12:53
JavaScript
redd_i, 2018-05-22 15:12:53

How to add js code to function in wordpress?

Hello. How to add arbitrary js code to Function.php so that it would be executed on the page? That is, do not include the Js file, but the code itself)
wp_enqueue_script( 'owl-carousel', EDGE_ASSETS_ROOT . '/js/modules/plugins/owl.carousel.min.js', array( 'jquery' ), false, true ); this is how the file is connected, but I don’t know how the code itself (

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan Hasanli, 2018-05-22
@azerphoenix

Hello!
As for me, it's better to connect a separate file (IMHO).
And if you need it through functions, then - https://wordpress.stackexchange.com/questions/1517...

add_action('wp_head','woocommerce_js');

function woocommerce_js()
{ // break out of php ?>

jQuery(document).ready(function($) {
    $(".woocommerce-cart").html(function(i, val) {
    return val.replace(" →", "");
    });
    $(".woocommerce-cart").html(function(i, val) {
    return val.replace("← ", "");
    });
});
<?php } // break back into php

M
Max Medar, 2018-05-22
@MedVedar

Like this:
How to add js pieces of code to Wordpress?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question