Bill: How WordPress Opens the post format

Source: Internet
Author: User

Found a lot of "old" WordPress theme usage is very large, although part also in the version of the WordPress upgrade and "Upgrade", just fix the bug, WordPress new features are not used. And most of the domestic WordPress theme makers, but also on the basis of these themes to create, inevitably a bit outdated. Today, Maple Bamboo Dream introduces the content of post format that is not new, useful but less supported by themes.

Introduction to post Format

Post format is a new feature introduced by WordPress 3.1. Themes can display articles in different ways depending on the post format. WordPress provides a number of standard post format, as WordPress theme developers do not have to support each of the post format, of course, can not support any one. The type of post format cannot be added by themes or plugins.

Simply put, if a WordPress theme supports post format, you can choose the post format type to display this article in different ways when the article is published.

It was possible to customize the presentation of articles by different categories of articles, or by Post_class (). Using post format, you can use CSS more intently to beautify your article presentation.

Post format type

Here is the type of 9 post format that WordPress supports, and if the topic supports these types, you can select them when you publish the article.

Note: There is no need to change the content of the article, just change the post format of the article to display the article in different ways. How it is presented depends on the support of the topic you are using.

    • Aside
    • Audio
    • Chat
    • Gallery
    • Image
    • Link
    • Quote
    • Status
    • Video

If no post format type is specified, the standard type is selected by default. The standard type does not belong to the post format type.

The following is the type of post format supported by the topic twenty thirteen.


Add Theme Support

If you want the topic to support post format, simply add the Add_theme_support () function to functions.php it, such as:

Array (' aside ', ' gallery ');

After you add the above code, you can select and type when you publish the article aside gallery . To add another type simply add the post format to the above array.

Add page Support

The above code by default simply adds the Post class article optional post format. If you want the page or the custom post type to support post format, you need to use the Add_post_type_support () function, which is also placed in functions.php . Such as:

// add post-formats to Post_type ' page' add_post_type_support (' page ', ' post-formats '//  Add Post-formats to Post_type ' My_custom_post_type 'add_post_type_support (' My_custom_post_type ', ' post-formats ' );

Using the Post format

Use Get_post_format () in the subject to detect the article type. If the article type is standard type, it is returned false . You can also use Has_post_format () to test.

if (Has_post_format (' video ')) {    echo ' This is the video format ';}

By calling the Post_class () function in the wrapper structure of the article, additional style classes are added and then laid out or beautified through the style sheet. Such as:

. Format-video. Post-title {    Display: none;}

Summarize

Although you can use a personalized style to process several of the above types of post format, it is recommended that you style it based on the meaning of post format in order not to confuse users.

Bill: How WordPress Opens the post format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.