WordPress: Featured Category shortcode

You can use this shortcode to display a group of posts on any page. For example, you may wish to create a page which displays your most important post categories like this demo. Please note, this is not the same as displaying a category on posts in your menu. For that, please see this guide instead.

To create this shortcode, you will first need to add your posts to categories. You can then display 3 posts from any category by using the shortcode below:

You can place the shortcode in any page/post. This will then display the feature in that position (the shortcode text itself won't be visible).

This shortcode can include the follow options:

title (required)
The text used for the main section title at the top.

category (optional)
The slug of the category to display. If you do not define a category then your 3 most recent posts will be displayed from all categories.

number (optional)
The number of posts to display in this category. Defaults to 3 if not set in the shortcode.

excerpt (optional)
Choose whether to display a post excerpt/summary under the title. Set to "false", "off" or "0" to stop the excerpt from showing under posts.

excerpt_length (optional)
Set to the number of words you would like to display in the excerpt (if enabled). For example excerpt_length="25" to show 25 words.

border (optional)
Whether or not you would like the title at the top to include a border. Set to "on" to display.

shape (optional)
The shape of the image. Options: portrait, square or landscape. Defaults to landscape if not set.

view_all_button (optional)
Whether or not to display a "View All" button under the posts. Set to "on" to display. By default this button will show the words "View All". You can change this by using the view_all_button_text parameter - e.g. view_all_button="Click here to view more"

location (optional)
Whether or not to display the post's location above the title. The location of the post can be site via the "Extra Post Options" section of the post editor. Please note this option might not be available in some themes. Set to "true", or "on" to display.

For example, here is the shortcode with the border option added:

This would create the following feature on the page:

Click here to see a real example of how 3 shortcodes can create a more dynamic page. The shortcodes used on that page are:

[pipdig_category_section title='Latest Posts' border='yes']
[pipdig_category_section category='fashion' title='Latest in Fashion' border='yes']
[pipdig_category_section category='beauty' title='Beauty Favorites' border='yes']

This allows you to create a page which shows a good selection of your posts and content. You may wish to mix this with a static front page to give a more magazine feel to your blog.

Was this article helpful?