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]

Align Ozh’ Admin Drop Down Menu Plugin’s Menu Icons Nicely

Ozh’ Admin Drop Down Menu plugin is a really time saver in admin area. And it unclutters the admin view. There is only one small glitch in menu icon aligning, if you have plugins with their own menus. This can be fixed with small code change though…

Default view
ozh-admin-menu-1.png

In file adminmenu.css.php line 252, change

padding:5px 1px 0;

to

padding:5px 2px 0 6px;

New view
ozh-admin-menu-2.png

I tested CSS with Chrome 5, Firefox 3.6 and Safari 5.

Resources for Ozh’ Admin Drop Down Menu

How to Change the Order of WP Review Site Rating Categories

Changing the order of rating categories is a bit tricky and needs database value altering. Copy the value of rs_categories from database table options.

a:4:{i:3;s:32:"Potential Value for Making Money";i:1;s:27:"Works Without Altering Code";i:2;s:18:"Essential Features";i:0;s:14:"Overall Rating";}

Paste the value to text editor and add line feeds after and before brackets and after after every semicolon, as in the example.

a:4:{
i:0;s:14:"Overall Rating";
i:1;s:27:"Works Without Altering Code";
i:2;s:18:"Essential Features";
i:3;s:32:"Potential Value for Making Money";
}

No you can copy and paste lines to put them into the order you like.

a:4:{
i:3;s:32:"Potential Value for Making Money";
i:1;s:27:"Works Without Altering Code";
i:2;s:18:"Essential Features";
i:0;s:14:"Overall Rating";
}

And after that remove all the line feeds, copy and paste the value back to database.

a:4:{i:3;s:32:"Potential Value for Making Money";i:1;s:27:"Works Without Altering Code";i:2;s:18:"Essential Features";i:0;s:14:"Overall Rating";}

That's it, now the order is changed in every place where ratings are showed.

Break Down the Content on Your Website by Using Tags

There are several ways to arrange WordPress website content. By categories, by dates and by tags. Even tagging is one of the most powerful one, it's not always easy or straightforward.

By using tags you have a powerful way to break down the content on your website. This break down can provide different paths to your content for both humans and search engines. This break down becomes more useful to humans if you link words or tags within the main content.

All categorizing methods bring duplicate content problem. You can use Robots Meta plugin for date archives to use “noindex/follow” robots tag. For category pages you can use Thesis theme's functionality, teaser plugin or “more” tag to show only teaser content.

This break down of content is extremely effective for targeted advertising or affiliate links.

[Source Graywolf's SEO Blog – How to Use Tags on Your Blog or Website]

How to Add WordPress 3.0 Menu to Thesis 1.7

custom_function.php

function wp3_nav_menu() {
  add_theme_support('nav-menus');
  wp_nav_menu('fallback_cb=thesis_nav_menu');
}
add_action('thesis_hook_before_header', 'wp3_nav_menu');
remove_action('thesis_hook_before_header', 'thesis_nav_menu');

custom.css

.menu .current-menu-ancestor > a, .menu .current-menu-parent > a { background-color: #F0EEC2; }
.menu .current-menu-item > a { background-color: #FFF; }

How to Setup WordPress

Let's do a basic setup of WordPress.

WordPress Log In

media_1262784728501.png

Log in to your WordPress.

WordPress Dashboard

media_1276539046824.png

Welcome to your WordPress site's dashboard! 1) You may change you admin password.

Add New User

media_1276539138139.png

Add yourself as a new user, log out and log in with your own username. For security reasons you may disable default admin user. Log out and log in with your new username.

Screen Options

media_1262722931229.png

You can adjust Screen Options to choose add or remove Dashboard widgets.

General Settings

media_1276540033024.png

Writing Settings

media_1276541094026.png

1) Size of the post box: 16 lines
2) There is a debate whether to use one ping service, multiple ping services or none. I would start like under the radar with none. Later on, when my site gets momentum, I could add maybe one or two ping services: http://rpc.pingomatic.com/ or http://ping.feedburner.com/ and http://rpc.blogcatalog.com/.

Reading Settings

media_1276541224029.png

Discussion Settings

10-06-14_215511__Firefox_Discussion_Settings___Social_Media_Cheat_Sheet___WordPress.png

1) Enable threaded (nested) comments is a nice feature. 2) I don't want to show default graphics.

Media Settings

media_1276545369456.png

Privacy Settings

media_1276545334294.png

Permalink Settings

media_1276545450642.png

1) Either /%postname%/ or /%category%/%postname%/. For time relative blog maybe /%year%/%monthnum%/%day%/%postname%/.

Miscellaneous Settings

media_1276545595033.png

Hello World!

media_1276546086456.png

How to Install WordPress

Let's install WordPress by downloading WordPress files from WordPress website, uploading files to your web hosting server and extracting all the files. After these small steps we are ready to setup our WordPress site. If you need some more information, check out the Famous 5-Minute Install Guide for WordPress.

WordPress Website

wpid58-media_1262782201186.png

Go to WordPress website.

Link to WordPress Download Page

wpid57-media_1262782043615.png

1) Click the Download WordPress link on the front page to go to download page.

WordPress Download Link

wpid56-media_1262781973001.png

1) Click the Download WordPress link on the download page to download the zipped file.

WordPress Zip File

wpid59-media_1262782508249.png

Save WordPress zip file to your disk.

Your Hosting Providers cPanel Account

wpid61-media_1262783103166.png

Go to your hosting providers cPanel account and 1) click File Manager. As a hosting option I prefer HostGator.

cPanel's File Manager

wpid60-media_1262782927583.png

On File Manager page 1) click Upload.

File Manager's Upload Files

wpid62-media_1262783274853.png

On Upload files page 1) click Browse and choose the WordPress zip file from you own computer. We will now upload the file to server.

WordPress Zip File Extract

wpid63-media_1262783495345.png

1) Select WordPress zip file and 2) click Extract.

Extract Location

wpid64-media_1262783692785.png

Choose to extract to /public_html folder and 1) click Extract Files.

Extraction Ready

wpid65-media_1262783830497.png

Zip file extracting takes couple seconds. 1) Click Close.

WordPress Folder

wpid66-media_1262783936071.png

Extractin WordPress zip file puts all the files into /public_html/wordpress folder. You want to move those files to /public_html folder. 1) Double click wordpress folder name to move into that folder.

File Selection

wpid67-media_1262783996184.png

1) Click Select all.

Move Files

wpid68-media_1262784098115.png

Enter /public_html and 1) click Move Files. Now you should have all WordPress file in /public_html folder. You may delete the uploaded zip file.

Install WordPress

wpid69-media_1276530236751.png

We are now ready with copying WordPress files to your server. Open your website and 1) fill in your blog title and 2) e-mail address. 3) You want to allow your blog to appear in search engines unless you are setting up a private blog or a website. 4) Click Install WordPress

Success!

wpid55-media_1262713624276.png

You have now installed WordPress. Next step is to log in and setup WordPress. Remeber to 1) copy the password!

How to Add Website Favicons to Your WordPress Comments in 5 Minutes

There's a url you can access on Google.com that will give you the favicon for the requested website.

http://www.google.com/s2/favicons?domain=www.highmac.com

So to use this in your theme you can place a little function in functions.php:

function bm_getFavion ($url = '') {
	if ($url != '') {
		$url = parse_url($url);
	}
	$url = 'http://www.google.com/s2/favicons?domain=' . $url['host'];
	return $url;
}
[Binary Moon: Add Website Favicons to Your WordPress Comments in 5 Minutes]

Scroll to Top