Category / PHP

Many developers use the HTML comment in order to analyse the page by using the “view source” feature provided by most all browsers. However, these comments will be visible for everyone. Also, they are sent from the server to the client and that could take a lot of needless bytes. If you don’t need to […]

Read More

If you have used a custom query ( for example with query_posts()) before standard WordPress flow, you might reset the internal query to avoid strange result in sidebar or other sides:

 

Read More

A simple way to create a slug:

Read More

In WordPress, you can organise the category with a relationship parent/child. This means that a single post belongs to multiple categories. Let’s see how to get the parent category of a post:

     

Read More

Sometimes, you may wish to check a POST variable and when it is not set then get a default value. The first approach could be:

Read More

Administrator or subscriber? Let’s see a quick way to check it!

Shorter

Of course, you can check also the rest of WordPress roles, such as “subscriber” for example.

Read More

Let’s see how to convert a date from yyyy-mm-dd hh:mm:ss to yyyymmddhhmmss. This can be useful when you’ll use sort functions for example (such as asort()). Elegant:

Obvious:

Insane:

Read More

Does anyone how to cut a long string by words?

Read More