Adding jQuery UI elements to WordPress page

Using jquery-ui widgets requires a couple of steps. You will need to add the appropriate markup for your widget. I’ll use the slider as an example. I just created a new page and added the markup below to it in the text editor in the WordPress admin: <div id=”sample-theme-slider”></div> You’re going to have to have … Read more

Ajax form submit not working, returns 0

The action: ‘ajax_contact’ part in: var data = $form.serialize(); console.log(data); $.ajax({ url: ajax_contact.ajaxurl, dataType: ‘json’, action: ‘ajax_contact’, data: ajax_contact.data, is most likely the cause here, that your ajax request is failing. Move the action part into the data set instead. Since you’re serializing the form data, you could try to add: <input type=”hidden” name=”action” value=”ajax_contact” … Read more

FacetWP – conditionally display facet labels

Your code seems identical to FacetWP’s. The only variable I can think of is code placement. You might not be placing the code where it belongs (functions.php or a plugin). A quick fix would be adding their code to your theme’s functions.php: function fwp_add_facet_labels() { ?> <script> (function($) { $(document).on(‘facetwp-loaded’, function() { $(‘.facetwp-facet’).each(function() { var … Read more

WP Customizer compare and set a value via javascript

You’re binding changes to themeb_scheme via an anonymous callback function with the parameter value as the new setting of themeb_scheme. This should work: wp.customize( ‘themeb_scheme’, ‘themeb_footerbg’, function( themeb_scheme, themeb_footerbg ) { themeb_scheme.bind( function( value ) { if( value == ‘light’){ themeb_footerbg.set( ‘#eaeaea’ ); } else if( value == ‘dark’){ themeb_footerbg.set( ‘#323232’ ); } else { … Read more

I’m trying to set the cookie to my site to button on click action ,it is working on when user logged in .When user logged out it’s not working

Your script uses jQuery so you should make sure that: jQuery is enqueued on your site (it may be for logged-in users, especially admins, but not necessarily for logged-out users) your script is added with jQuery as a dependency so jQuery is available when your script runs I would use wp_add_inline_script() for this, like so: … Read more

WordPress error when replacing local jQuery by externally-hosted

The error message describes your problem quite clearly: Notice: wp_deregister_script was called incorrectly. Do not deregister the jquery script in the administration area. To target the front-end theme, use the wp_enqueue_scripts hook. You’re de-registering the script on the init hook: add_action(‘init’, ‘replace_jquery’); This hook runs for the back and front end, but the debugger isn’t … Read more

How register library to use jquery correct

You should use the built-in version of jQuery for compatibility reasons. All you need to do is to enqueue it: function theme_scripts() { wp_enqueue_script(‘jquery’); } add_action(‘wp_enqueue_scripts’, ‘theme_scripts’); Or just add it as a dependency for your script: function theme_scripts() { wp_enqueue_script( ‘my-script’, <PATH>, array(‘jquery’), … ); } add_action(‘wp_enqueue_scripts’, ‘theme_scripts’); But then… you have to remember, … Read more