Make Your WordPress Short URL Available

If you don’t already do so, you should make available your posts’s short url, especially if you are using a custom shortening software like YOURLS. “Why”, you ask? The less characters a reader has to work with, the better. It also makes it much easier to include a short url in newsletters and other publications. To show your short url on posts, open and edit your themes single.php file. Add the following code where you would like the short url to appear (I prefer it next to tags).

Once you’ve added the code, it should look similar to the…

Retrieving Database Information

Sometimes when writing a PHP application, you may need to retrieve the same database information from time to time throughout your PHP application. But how does one do so while staying true to the DRY concept? One answer is classes, but what if you don’t want to write a class just for one database table. Well, you can accomplish this with just one function:

Alternative Echo

Ever wondered how WordPress uses an echo shorthand without having to write out the word echo. Then wonder no further, it can be accomplished with just a few lines of code:

Return vs. Echo in Functions

I decided to start a new series called PHP Tips. I will be posting some tips and code snippets that will help people become better PHP developers. For the first one, is it better to use return or echo in your PHP functions? As you’ve probably been told, it depends on the situation. But here is a rule of thumb; if the function is only used once, then use echo. If the function is used more than once throughout the application, then it is best to use return and especially if you plan on manipulating that function before its output….