Posted in WordPress

5 Great WordPress Snippets

here is the 5 great and useful WordPress Snippets

Encoding Emails

To start i’d like you to introduce you a simple a great snippet using a WordPress native function called: antispambot(). It’s very easy to use but it’s very useful. The aim is to encrypt emails that are displayed on the frontend to avoid spambots to catch them and spam you or tour clients. Just place the email as a function parameter and WordPress does the job:

Change “Enter Title Here” placeholder

Next, when you add a new post, a new page or a new custom post type, the title field has a placeholder that says “Enter title here”. I really like when the placeholder text takes into account the post type you’re adding. For example if it’s a book, the placeholder should show “Enter Book Title Here”. To do so, use this code:

Check if a plugin is active

I created a few plugins dependent of BBpress. As i didn’t want my plugins to load if BBpress was missing i use this code. So simple, but so useful!

Get a user ID by its login

The other day i’ve been asked to create a referrer plugin for WordPress. My client wanted the urls to be more or less formatted like that: (where, obviously, “remi” is the referrer). To do so, i used the rewrite rules (see my previous post), and also a little function to retrieve the user ID from his login:

Automatically add content to every post

This is an example of how to add any type of content to every post of your WordPress install. You can for example use this method to add content to feed only, on posts that match some criteria etc…


Credit: Remi Corson


Freelance WordPress Developer,Pro Blogger,Projects Consultant
– Hire me for WordPress Projects:

Leave a Reply

Your email address will not be published. Required fields are marked *