Tag Info

New answers tagged

0

I finally figured this out. What ended up working is putting the script portion in a .js file within the theme directory, calling it using the functions.php in my child theme, and having the HTML input field and div tag in the body of the page. Hopefully this can spare others the same pain I went through.


0

Fixed: I have do it the right way, all the time. Now i found, that jquery was deregistered at the themes header.php file. I have deleted it and it works now.


4

Note that if any script in the header at all needs jQuery then it will bump it to header, regardless if it's changed to be enqueued for footer. So while changing it to be queued for footer makes sense it rarely works out when a lot of script stuff is going on.


-1

<?php function your_function() { echo '<p>This is inserted at the bottom</p>'; } add_action('wp_footer', 'my_function'); ?> You can use this hook. This is used to load the script in the footer try it let me know for any doubts.


1

Here is the problem If you try to register or enqueue an already registered handle with different parameters, the new parameters will be ignored. Instead, use wp_deregister_script() and register the script again with the new parameters. You will have to deregister jquery first, the register it again, but becareful because the empty string isn't ...


1

You have to localize script by using wp_localize_script function. In the admin side ajaxurl is already available. But in front end you have to localize script to define ajaxurl. Example: wp_enqueue_script( 'custom-ajax-request', '/path/to/settings.js', array( 'jquery' ) ); wp_localize_script( 'custom-ajax-request', 'MyAjax', array( 'ajaxurl' => ...


1

My first guess is that the values aren't the correct "type". Meaning you might be passing string values when the script expects integers, so try converting the values to integers first. jQuery(document).ready(function(){ var newsPerPage = parseInt( newsbox_parameters.newsPerPage ); var newsTickerInterval = parseInt( ...


3

the console is firing this error: TypeError: $ is not a function Could be a few things: WordPress loads jQuery in no-conflict mode so you may need to use jQuery instead of $ when making your selections jQuery('your-selector) Be sure that jQuery has loaded before you set your interval. Based on what I can see you may be trying to access if before ...


0

I got the solution for this question. I need to apply there Isotope append method, when adding posts to the frontend. Here is the Isotope append method.


0

The answer by Bjorn has some very good points, but I would avoid the javascript entirely, and use css similar to this: .mainNav li:active { background-image: transparent url('i/logo4.png') no-repeat; } Better yet, I would instead target the link itself using .mainNav a:active, which suggests your link targets aren't very large and you're using the li ...


0

You are missing <script> tags You are using the wrong jQuery variable name. If you want to use the $ alias you need to use noConflict as helgatheviking suggested or switch to "jQuery" instead of $ You are missing }); at the end of the code you posted above You should consider separating your JS into a separate file and use wp_enqueue_script in the ...


1

1.0.0? Really?! Anyway you could try the print_scripts_array filter: // Hack of wp_prototype_before_jquery() in "wp-includes/script-loader.php" function wpse157295_print_scripts_array( $js_array ) { if ( false === $jquery = array_search( 'jquery-core', $js_array, true ) ) // Now 'jquery-core', not 'jquery' return $js_array; $keys = array( ...


0

I solved my problem after a long time struggling, that's why I think I should list some tips for someone with a problem like this: If you change your javascript file, use ctrl+f5 to force reload the page and the resources. The caching almost got me crazy as I changed the file and the changes didn't take place. Use your browser's network analisys tool. In ...


0

@milo might have a point. WordPress loads jQuery in no-conflict mode. So this: $(document).ready(function(){ alert('ready'); }); becomes this: jQuery(document).ready(function(){ alert('ready'); }); if you want to use $ to not have to refactor your code just pass it to the function: jQuery(document).ready(function($){ ...


1

Do not use an external jQuery library, use the one that comes with WordPress. Use wp_enqueue_script to enqueue your scripts, like: wp_enqueue_script( 'jquery' ); Additionally be aware that WordPress sets the internal jQuery to noConflict() mode, more information about that here.


1

id="mySlide"is used twice in your markup. Just try removing slideExpr: '#mySlide' from your plugin options. Try using bloginfo('stylesheet_directory').


3

First, like many things in WordPress, it's not like someone decided "let's make this neat and convenient". It was more like someone slapped it together for something, then it got used more in admin, then it got used a lot in admin, then it became kind of practice to use it for non-admin as well. Or something along these lines. Second, it's not as much what ...


0

I discovered that the HoverIntent is optional for the drop menu plugin. I turned that off and everything is working correctly now.


0

According to the wp_register_script() Codex the first parameter handle should have a unique name. If we look at the paramters of the wp_register_script() function it breaks down like this: wp_register_script( $handle, $src, $deps, $ver, $in_footer ); So your wp_register_script() function should also break down into a similar way: wp_register_script( ...


0

No, in fact sanitizing the string you listed would remove the HTML. The sanitizing functions are meant for user inputted data like a form submission. You can't always trust the information they pass through. Sometimes hackers may input malicious code that would be executed on your site after submission if you did not run it through a sanitizing function ...


0

I had a similar issue, and it turned out to be a very outdated version of jQuery that I was enqueueing. You may wish to make sure that your Wordpress install and the subsequent jQuery file it includes is up to date, or if you enqueue from google like I do, make sure that's up to date.


-1

Use: wp_deregister_script('jquery'); wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/<version of required version of jquery>/jquery.min.js", false, null); wp_enqueue_script('jquery'); just before wp_head() I am not sure if this method is faster than ...



Top 50 recent answers are included