Tag Info

Hot answers tagged

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

If you want an example of how to do the dropdown filtering using ajax, then if you factor out your taxonomy dropdown into your "functions.php": function my_dropdown_categories( $taxonomy, $current_selected = '', $include = null ) { // Get all terms of the chosen taxonomy $terms = get_terms($taxonomy, array('orderby' => 'name')); // our ...


1

Use get_permalink (which returns the URL) instead of the_permalink (which prints the URL). Try: foreach ( $categories as $category ) { $link = get_term_link( $category ); $html .= "<li><a href='{$link}' data-filter='{$category->category_nicename}'>{$category->cat_name}</a></li>"; }


1

Before we jump into the script itself, I think it may pay off to review data types and operators in Javascript. I won't cover them all, but the ones relevant to your code are as follows: Data Types Boolean Boolean values are representative of "truth" and as such have two possible values: true and false. Note that within code, "true" and "false" are ...


1

I think you're looking for gform_enqueue_scripts which is simply a Gravity Forms specific version of the wp_enqueue_scripts hook. Either hook uses the wp_enqueue_script() function. That function can take a local script—usually using get_template_directory_uri() (theme), get_stylesheet_directory_uri() child theme), or plugins_url() (plugin) to reference the ...


1

In my case wp_mail() took over 90 seconds per email on form submits, bringing my site to a crawl. Totally forgot to correct the /etc/hosts config for my site, per the instructions below, now sendmail is < 3 seconds. https://www.digitalocean.com/community/questions/sendmail-is-slow-to-send-mail If you check your /var/log/mail.log you will probably find ...


1

I found the solution to my problem was to change my_data.data.my_key to my_data.my_key. For example: $( document ).on( 'click', '#button', function() { var my_data = wp.heartbeat.getQueuedItem( 'my_handle' ); alert( my_data.my_key ); }); The queued data can be easily accessed now.


1

There are roughly following factors to consider: Does it ship with WP core How easy it is to integrate with WP How easy it is to use in public WP extension Let's go over these for both. Bootstrap Bootstrap doesn't ship with WordPress core, so your implementation will need to provide it. While markup of the Bootstrap is rather pleasant by itself, it ...


1

Using your code you could something like this: function my_custom_admin_head(){ global $post; echo '<script type="text/javascript"> var js_post_id =' . $post->ID . ';</script>'; } And then just use the var js_post_id. You shoudl try to read about the script localization function and use it.


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( ...


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

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 ...



Only top voted, non community-wiki answers of a minimum length are eligible