WordPress has a standard set of post formats, like gallery, for example. A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post.
According to the wordpress codec: “The Post Formats feature provides a standardized list of formats that are available to all themes that support the feature. Themes are not required to support every format on the list. New formats cannot be introduced by themes or even plugins. The standardization of this list provides both compatibility between numerous themes and an avenue for external blogging tools to access this feature in a consistent fashion.”
Because themes are not required to support every (or any) format on the list, you need to begin by enabling the formats on our functions.php file. We are going to enable three formats: gallery, aside, and link. Right under register_nav_menus(), we can add Post Format Support and add _theme_support(). Also, we want to add post-formats. Then the second parameter will be an array of the types of formats we want.
Once that is done, under “New Post” in the admin you will see a dropdown from which you can choose Post Format.
Let’s create a new post of format aside. According to wordpress documentation, an aside is a post that is typically styled without a title. Similar to a Facebook note update.
When we view this post, it appears as a regular post. This is because we need to pass a second parameter in get_template_part(). Right now the only parameter we are passing is content, or excerpt. We need to add the parameter get_post_format(). Let’s add this to index.php:
We’ll need to make this edit to any other files that use get_template_part(), like archive.php, single.php, search.php…
This does not change anything in the formatting or presentation of the post. In order for that to happen, we need to actually create and format a content-aside.php file. Create a file called content-aside.php and paste the following code inside:
This post has no featured image, and no title. It just has the author and date post meta, and the post contents. Because it has no featured image or title (or “read more”), there is nothing that links to the post itself (although the page does exist). Instead, it will appear as an “aside” on archive pages and the home page if it displays posts.
If you want to make it stand out further, you can style it:
Next, we’ll make a link post format. We start by creating a file called content-link.php. We want the link to be a post that contains nothing but the link. No title, no meta, just the content of the post which will generally simply be a link. Add the following to that file:
We can then style this so that it stands out on the archive and/or home page(s):
Finally, we’ll add a gallery page. This will have a title, but no post meta. Create a file called content-gallery.php, and add this to the file:
Now go ahead and create a gallery. Note that in wordpress, you have a number of controls regarding the gallery. You can control the number of columns, and you can also control what the image links to: an image, a page containing just the image, or, if you make no selection, no link at all.
We can style the gallery so that it stands out on the archive and/or home page(s) by adding something like this to the styles.css file: