calling JS to custom menu design

Surely. function loadMenuScripts() { wp_enqueue_script( ‘main’, get_template_directory_uri() . ‘js/main.js’, array( ‘jquery’ ), ”, false ); } add_action( ‘wp_enqueue_scripts’, ‘loadMenuScripts’ ); Additionally, if you need to load it in the footer, go ahead and change the action to: add_action( ‘wp_footer’, ‘loadMenuScripts’ ); Also, it seems as if this is an option for users. Before enqueueing, check … Read more

Ajax by worpdress affects called jquery inside template file

This will not work: function widget_data(){ include get_template_directory() . ‘/inc/wid/card/widget-card.php’; wp_die(); } The include statment includes the “widget-card.php” only into the file and not the output stream. You have to redirect the output into a variable and then output the value via “echo”. function widget_data(){ ob_start(); include get_template_directory() . ‘/inc/wid/card/widget-card.php’; $output = ob_get_clean( ); echo … Read more

bundled jquery in theme js not working with wp_localize_script

You can’t use wp_localize_script with jquery. this function use the WP_Scripts::localize() function which have a condition right in the start. You can see it in the file \wp-includes\class.wp-scripts.php line 414 if ( $handle === ‘jquery’ ) $handle=”jquery-core”; You can do something else like add the script with other action like wp_head if your script is … Read more

WordPress Customizer: Check for value of CSS selector and replace it

You’re using a selector in this: if ( $( ‘#customizer-preview .site-title’ ).length > 0 ) { $( ‘#customizer-preview .site-title’ ).remove(); } It’s just like styling CSS property, if you were to add that rule to a style sheet, it would add styles for the element #customizer-preview .site-title So the code above is saying if an … Read more

How to inject data content from external json into a modal, using UIkit?

Ok. The solution I found out, was more simple than I thought. On the script use “jQuery” instead of “$”. HTML trigger: <a href=”#myModal” onclick=javascript:openModal({{id}})><article>… </article></a> function openModal(id){ jQuery.ajax({ type: “GET”, url: ‘https://www.example.json’ + id, dataType: ‘json’, success: function(data) { var data = data.T.ads; var infoModal = jQuery(‘#myModal’); infoModal.find(‘.uk-modal-title’).html(data[0].brand + ‘ ‘ + data[0].model); htmlData=”<p>” … Read more