WordPress Let the article use a different template

Source: Internet
Author: User

| Custom Post Template plugin.

Step: 1, install the custom post template plugin. WP download: dot me

2. Copy the single.php and rename it, for example single-new.php

3. Open the renamed file and add the code at the top

<?php/*template Name posts:new*/?>
| function specifies the category template

another is to use the function to specify the classification article template: Point Me

Add_action (' template_include ', ' load_single_template ');    function Load_single_template ($template) {$new _template = ';      Single post template if (Is_single ()) {Global $post; ' WordPress ' is category slugs if (has_term (' WordPress ', ' Category ', $post)} {//Use template file single-      wordpress.php $new _template = locate_template (Array (' single-wordpress.php ')); }} return ('! = $new _template)?  $new _template: $template; }


WordPress lets articles use different templates

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.