What are Shortcodes?


Shortcodes, which many plugins take advantage of, are an easy and quick way to insert special kinds of content into your posts or pages.

A shortcode typically looks something like this one from a plugin that is supposed to display the number of categories on a site:

[catcount]

You just pop your shortcode into your post, and then behind the scenes everything gets called into the post in the way it should.

So in the case above, I might write a post that says the following:

The total number of categories is [catcount].

If I have 21 categories, then when the post is published it will read:

The total number of categories is 21.

If I add a category, then that number will automatically get bumped up to 22. Continue reading

Advertisements

Difference Between Posts and Pages in WordPress


Often WordPress beginners get confused between posts and pages. By default, WordPress comes with two content types, posts and pages. As a beginner, you are probably wondering what is the difference between them? It seems to have similar fields in the dashboard. It seems to look the same on the website. Why do I need both? When should I use posts? When should I use pages? In this article, we will explain the difference between posts vs. pages in WordPress.

Posts

If you are using WordPress as a blog, then you will end up using posts for majority of your site’s content. Posts are content entries listed in reverse chronological order on your blog’s home page. Due to their reverse chronological order, your posts are meant to be timely. Older posts are archived based on month and year. As the post gets older, the deeper the user has to dig to find it. You have the option to organize your posts based on categories and tags.

Because WordPress posts are published with time and date in mind, they are syndicated through the RSS feeds. This allows your readers to be notified of the most recent post update via RSS feeds. Bloggers can use the RSS feeds to deliver email broadcasts.

Posts encourage conversation. They have a built-in commenting feature that allows users to comment on a particular topic. You can go to your Settings » Discussion to turn off comments on older posts if you like. Continue reading

Easy way to data filter and validate in php


Before php 5.2.0 when we have to validate or filter user data, we normally use regex and some php functions. Some of those regex are difficult to understand. So normally most of the coders search in google to collect the correct regex to validate data and also use some php functions to filter data.

In php 5.2.0 a new extension is provided named filter to make these filter tasks much easy.  You can install it in your linux distro by simply typing in shell  pecl install filter

Before proceeding next at first check the available filters in your system:

echo '<pre>';
print_r(filter_list());
echo '</pre>';

Output in my system:

Array
(
    [0] => int
    [1] => boolean
    [2] => float
    [3] => validate_regexp
    [4] => validate_url
    [5] => validate_email
    [6] => validate_ip
    [7] => string
    [8] => stripped
    [9] => encoded
    [10] => special_chars
    [11] => unsafe_raw
    [12] => email
    [13] => url
    [14] => number_int
    [15] => number_float
    [16] => magic_quotes
    [17] => callback
)

Continue reading