New answers tagged

0

Thanks to @Mark Kaplun that spotted the actual issue. jQuery did not load before wp_enque_script was executed. So I hooked the function js_css() into init like this: add_action( 'init', array( $this, 'js_css' ) ); and that solved the problem! :-) (Very strange that this even worked on site1 though)


1

No idea why the change of folder name makes a difference, but you should add jquery as dependency in your enqueue wp_enqueue_script( 'wtfjs', plugins_url( '/js/wtf.js' , __FILE__), array('jquery') );


0

You have to load your javascript Snippet inside your header. You'll have to options: Edit your themes header.php and put the code before the closing tag Insert your code into the header with a custom function inside your functions.php function my_custom_js() { echo '<script type="text/javascript"> jQuery(document).ready(function($){ ...


2

You can enqueue all your scripts the same way as you enqueue jQuery. Register and enqueue all your Javascripts like this (in your load_jquery function) wp_register_script ( 'yourscripthandle', //string $handle: a string to identify this script get_bloginfo( 'template_url' ) . '/js/yourcustomjs.js', //string $src: Path of your script file array ...


0

So I have done figured out a solution using php Ill explain below: So I created a var and called it white. It has a empty string that I used and an if statement then I used the WordPress function is_front_page <?php $white = ""; if( !is_front_page() ) { $white = 'scrolled'; } ?> Then in my Navbar class I added this: <?php ...


0

Most WordPress themes take advantage of a function called body_class() which outputs specific classes to the body tag. Implementation looks something like this: <body <?php body_class(); ?>> This will put a unique class on the homepage of your website that won't be on any of the other pages so you could target that specifically in jQuery or ...


0

Okay. Got it working.... I used the simple version: add_filter( 'admin_post_thumbnail_html', 'basic_add_opacity_to_feature_thumb_box'); //same as before function basic_add_opacity_to_feature_thumb_box( $myhtml ) { $selected_option = get_post_meta( get_the_ID(), 'basic_opacity', true ); // get the current value for ( $i = 0; $i <= 1; $i = $i + 0.1 ) { ...


0

Ok after trying a bunch of different plugins, scripts, and custom coding, I've come across one that seems to be perfect! Only thing now is to figure out how to implement it in my site. My Solution


0

I could be wrong but imho is it better to use the 'full' $handle (string) (Required) Name of the script in your case: script-pricing instead of pricing. /** * Register/Enqueue my script into footer for better page load * Read more: {@link http://www.tutorialrepublic.com/codelab.php?topic=faq&file=jquery-show-hide-div-using-radio-button} * @version ...


0

use this: var j = jQuery.noConflict(); now everywhere in script JQurey is needed use j instead of $ or JQuery also your enqueue line should be like this: wp_register_script('myjs',get_stylesheet_directory_uri().'/js/my_script.js',array('jquery'),false,true); wp_enqueue_script('myjs'); you can read more here P.S: so your updated code should be : ...


-1

Please use jQuery('a[title*="Read more"]').html("View Car"); I have updated your codepen and its working fine.


0

Most likely, the cause of your problem is that jQuery is in compatibility mode. This means that you can't use the '$' shortcode. To get your Javascript code to work, replace all '$' with 'jQuery' Or, wrap your code in an anonymous function, like this: jQuery(document).ready(function( $ ) { // Put your jQuery code here. }); See: ...


0

I found the problem with my enqueue statements. There was a space ahead of the handle name of the wp_enqueue_scripts statements for both "tablesorterjs" and "tablesorterfunctions". Once I removed the space in front of the handle name, the scripts enqueued. wp_register_script( 'tablesorterjs', plugins_url( '/js/jquery.tablesorter.js', __FILE__ ), ...


1

Here's how localization works. The first thing you need to do is register your script with WordPress. This pretty much tells WordPress where the script is located, what version it is, any dependants ( like jquery ), and whether it will be located in the header or footer. More importantly you need to give it a unique identifier which you'll be able to ...


0

By the time woocommerce_checkout_fields filter is run, the arrays for billing and shipping have already been created. You can see that here: https://docs.woothemes.com/wc-apidocs/source-class-WC_Checkout.html#101 If you want to effect the default fields, use this hook. function wpse215677_checkout_fields ( $fields ) { ...


0

If you go with @Rituparna's solution, try this: Don't forget to add <a href="#" class="close">X</a> in your container. jQuery(function($){ $(".plink").on('click', function( event ){ event.preventDefault(); // cache the link clicked on var link = $(event.target); // use the link attr to target the desc ...


0

<div class="row"> <?php $args = array('post_type' => 'team', 'category_name' => $a); $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <div class="tab_heading col-md-4"> <div class="wrapper"> <a class="plink" href="#tab-<?php echo ...


0

I was missing a crucial line in my AJAX query. Without this option, the call fails, and the pages refreshes. processData: false,


3

Try using preventDefault(), it's a jQuery function for preventing default actions called by the browser. First you should call an event handler by firing up your submitter. You can do this as follow: $('#my_upload_form').submit(function (event) { After catching a submit and giving an event with it, you should prevent the default refresh of a browser: ...


0

Try using JQuery instead of dollar sign: jQuery(document).ready(function(){ jQuery('.site-title').addClass("hidden").viewportChecker({ classToAdd: 'visible animated fadeInUp', offset: 100 }); }); </script> Here is some reading stuff about the subject: ...


1

Enqueue your script and use wp_localize_script to pass data. function wpd_scripts() { wp_enqueue_script( 'wpd_script', get_stylesheet_directory_uri() . '/js/script.js', null, null, false ); wp_localize_script( 'wpd_script', 'WPD', array( 'stylesheet_dir' => ...


1

You can pass an array of settings to the editor instance. For possible values please refer to the tinymce documentation, in your case 'init_instance_callback' might be helpful. https://www.tinymce.com/docs/configure/integration-and-setup/#init_instance_callback wp_editor('', 'sedemoeditor', array( 'tinymce' => array( ...



Top 50 recent answers are included