admin

How to Customize WordPress Tag Cloud Widget

Display All Tags

The number of Tag Cloud widget tags are limited to 45 by default. Default format of the cloud display is flat. To set number to unlimited and format to list:

function set_tag_cloud_args($args) {
	$args = array('number' => 0, 'format' => 'list');
	return $args;
}
add_filter('widget_tag_cloud_args','set_tag_cloud_args');

How to Display Text to Only Logged in WordPress Users

Create Shortcode for Logged in Users

function logged_in_only_shortcode($atts, $content = null) {
    if (is_user_logged_in() && !is_null($content) && !is_feed()) {
        return $content;
    }
}
add_shortcode('logged_in_only', 'logged_in_only_shortcode');

To use this shortcode in your post use the following code.


Create Shortcode for Logged Out Users

function logged_out_only_shortcode($atts, $content = null) {
    if (!is_user_logged_in() && !is_null($content) && !is_feed()) {
        return $content;
    }
}
add_shortcode('logged_out_only', 'logged_out_only_shortcode');

To use this shortcode in your post use the following code.

User is logged out.

Resource: Display Text To Only Logged In WordPress Users

How to Remove WordPress’ jQuery and Use Google’s CDN Version Instead?

Why Use Google’s CDN?

The three most commonly cited reasons to dequeue WordPress’ bundled version of jQuery in favor of Googles are:

  1. Decreased Latency.
  2. Increased Parallelism.
  3. Better Caching.

Why NOT Use Google’s CDN?

  1. WordPress takes great care to make sure its bundled libraries are fully compatible with other bundled scripts. jQuery is loaded in “no conflict” mode to prevent any potential script collisions over the $ variable in the global namespace.
  2. If you load jQuery 1.9 yourself from Google’s CDN, you’ll miss out on the jQuery Migrate plugin and end up breaking several themes and plugins that depend on these deprecated APIs.
  3. Also, WordPress is taking steps to prevent you from dequeueing jQuery on the back end at all.

Source: Don’t Dequeue WordPress’ jQuery

Then, How to Remove WordPress’ jQuery and Use Google’s CDN Version Instead?

function jquery_cdn() {
   if (!is_admin()) {
      wp_deregister_script('jquery');
      wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3');
      wp_enqueue_script('jquery');
   }
}
add_action('init', 'jquery_cdn');

Comment by Nathan Rice:

This is almost sure to cause warnings if you have WP_DEBUG on. The reason being that wp_register_script should only be called on the wp_enqueue_scripts action hook.

Sources:
How to load jQuery from Google CDN
Replace default WordPress jQuery script with Google Library

Scroll to Top