You can show number of your Twitter followers by using this function. If you are a WordPress user, simply copy and paste it into the functions.php file. Call the function like: That’s it. Now you can brag with your popular Twitter account
Display comments on index page
This is a code snippet that allows you to display comments below each post on index pages or any other archive page. Just paste it in the loop in the appropriate file (index.php, archive.php etc).
Email to a friend script
Maybe you’ll want to add a link that allows sending of current URL emails to a friend. This is how the script looks:
Hacking Contact form 7 – add onFocus and onBlur function
There is a great WordPress plugin Contact form 7. It has a lot of customizable features that make my clients life easier. I missed support of onFocus and onBlur functions; click on the input field and the default value disapears. This is a simple jQuery script that does what I needed: Here is a small [...]
How to add field to user profile page
Justin Tadlock published a piece of code I needed recently. This snippet allows you to add any fields to the user’s profile page. Just copy and paste the code in to the functions.php.
How to get user info
This function allows you to get info about any user: if you want to find out if the user is admin do it like this: This is useful when you want to get info about the current user:
Is a number divisible by another number?
This is yet another very useful function. Especially when you need to know if you can divide some number by another one. Possible use of the code: Every second division post-content will have margin-right: 20px;
How to add author’s gravatar to the post
There are two ways of how to do it. The first one is adding real gravatar based on the author’s email. This will display gravatar with size 80 pixels. The second is adding our custom image based on the original author’s ID:
Does the page have subpages?
That’s the question. You can find out if a page has child pages with this if – else statement:
Display recent comments with avatar
From time to time clients ask me implement recent posts. But how about displaying recent comments? And even add gravatar? Here is a code that displays eight recent comments with avatar image.