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.

[logged_in_only]User is logged in.[/logged_in_only]

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.

[logged_out_only]User is logged out.[/logged_out_only]

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

How to Add an Admin Bar Menu Link

add-wordpress-admin-bar-menu-link

Here is an example code how to add Editorial Calendar plugin admin bar menu link:

function add_editorial_calendar_admin_bar_link() {
	global $wp_admin_bar;
	if (!is_super_admin() || !is_admin_bar_showing())
		return;
	$wp_admin_bar->add_menu(array(
		'id' => 'editorial_calendar_link',
		'title' => __('Editorial Calendar'),
		'href' => __('http://' . strtolower($_SERVER['HTTP_HOST']) . '/wp-admin/edit.php?page=cal'),
	) );
}
add_action('admin_bar_menu', 'add_editorial_calendar_admin_bar_link', 75);

The UI Problem of WordPress Plugins and Themes

Trent:
Our old theme options had WordPress like tabs, and check boxes galore. We then opted for making our theme options intuitive, and pretty. They look more like an iOS device then they do WordPress, and guess what? Our support requests dropped significantly, and we never have to link users to our documentation anymore.

Survey: WordPress Continue to Dominate Open Source CMS Market

According to water&stone, WordPress, Drupal, and Joomla continue to dominate open source market in 2011 with WordPress clearly leading.

Survey looked at downloads, installations and third-party support.

Downloads a week

  1. WordPress: 640,000
  2. Joomla: 86,000
  3. Drupal: 23,000

Download numbers are really not that accurate, because there are checkouts from repositories and web hosts' one click installs.

Alexa One Million

  1. WordPress: 53.6%
  2. Joomla: 9.6%
  3. Drupal: 6.4%

BuiltWith Installs

  1. WordPress: 4.2 million
  2. Joomla: 1.7 million
  3. Drupal: 308,000

Books in Print

  1. WordPress: 83 books, 23 released in 2011
  2. Drupal: 64 books, 22 released in 2011
  3. Joomla: 65 books, 13 released in 2011

It's interesting that Drupal books new releases are so close to WordPress. Maybe that tells about active developer community?

76 WordPress Tricks

Jeff Starr has an extensive list of WordPress code snippets:

  1. WordPress Shortcodes
  2. WordPress Permalinks Outside of the Loop
  3. Custom Message to Returning Visitors
  4. Recently Updated Posts and Pages
  5. Custom Content to Search Engine Visitors
  6. Last Modified Time and Date for Posts
  7. Display Total Number of Trackbacks and Pingbacks
  8. Display Recently Registered Users
  9. List all of Your Site’s Posts
  10. List WordPress User Information
  11. Display List of Scheduled Posts
  12. Display Private Posts to Logged-in Users
  13. Display Posts from Exactly One Year Ago
  14. Custom CSS Styles for Recent Posts
  15. New WordPress-2.7 Comments Loop
  16. Backwards-Compatible Comment Templates
  17. Disable WordPress Post Revisions
  18. Limit WordPress Post Revisions
  19. Remove WordPress Post Revisions from the Database
  20. Reduce Comment Spam by Blocking No-Referrer Requests
  21. Prevent Google Analytics from Tracking Admin Pages
  22. Meta Descriptions without a Plugin
  23. Differentiate Between Posts Depending on Presence of Excerpt
  24. Modify the wp_options Table via the WordPress Admin
  25. Alternate Comment Styles
  26. Automatically Remove Code Mistakes in Posts
  27. Automatically Disable Comments and Trackbacks in Old Posts
  28. Access Post Data Outside the Loop
  29. Display Posts for a Specified Time Period
  30. Unique Single Post Templates for Different Categories
  31. Display Performance Statistics for WordPress Pages
  32. Custom Post Thumbnails in Two Steps
  33. Highlight Author Comments
  34. Easy Random Posts
  35. Display Dates for Groups of Posts
  36. Display a Sticky Post in the Sidebar
  37. Display Latest Comments without a Plugin
  38. Display Most Commented Posts without a Plugin
  39. Change Permalinks from Date-Based to Post-Date Only
  40. Test for Sub-Pages
  41. Multiple Widgetizable Sidebars
  42. Remove Fancy Quotes from Comments
  43. Display a List of All Untagged Posts
  44. Easy Display of Custom Headers, Footers, and Sidebars
  45. A Better Way for Users to Logout
  46. Display a Custom Message on a Specific Date
  47. Display Three Columns of Posts
  48. Disable WordPress Search Functionality
  49. Display Posts with Specific Custom Fields
  50. How to Number Your Comments, Pingbacks, & Trackbacks in 2.7+
  51. How to Number Your Comments Using the Classic Loop
  52. Invite Readers to Comment via Feed
  53. Display the Total Number of Users for Your Blog
  54. Automatically Insert Content into Your WordPress Post Editor
  55. How to Prevent Duplicate Content
  56. Conditionally Display Full Posts or Excerpts
  57. Display Related Posts without a Plugin
  58. Drop-Dead Easy Styles for Author Comments
  59. Display Posts Upcoming Scheduled Posts
  60. Display Automatic TinyURLs for Your Posts
  61. Implement a Site-Maintenance Page for Your Blog
  62. Display the First Image from Each of Your Posts
  63. Display Most Popular Posts without a Plugin
  64. Automatically Highlight Search Terms
  65. Automatically Disable Widgets
  66. Display All Images from Your Post Content
  67. Display Category List in Two Columns
  68. Show Ads or Other Content Only in the First Three Posts
  69. A Better Way to Display Recent Comments without a Plugin
  70. Selectively Disable Automatic Post Formatting
  71. Browser Detection via WordPress’ body_class Function
  72. Get Post or Page Contents as a PHP Variable
  73. Simple Example of How to Use WordPress Cron
  74. Add More Default Avatar Choices to the WordPress Admin
  75. Add a Private Page to Your Navigation Menu
  76. How to Add Additional Links to wp_list_pages
[Perishable Press: Stupid WordPress Tricks]
Scroll to Top