Wordpress topic creation tutorial (10): create a single article page template single. php

Source: Internet
Author: User
In the previous tutorial, we have only completed index. php: This file can be used on the homepage or archive pages such as categories and tags. in this tutorial, we will create a specific article page-Single-page document template, if we don't have one, but the page template is single. php

In the previous tutorial, we have only completed index. php: This file can be used on the homepage or archive pages such as categories and tags. in this tutorial, we will create a specific article page-Single-page document template, if we don't have one, but the page template is single. php, then index will be used. php file instead, but for the single page of the article, we still need to add some other information, such as copyright statement, related articles, comments, etc., so we should create another template, the downloaded topic folder contains the single. php file. You can try to delete this file, and then check the effect of using index. php to display the article.

Open the single. php file under the topic folder in the editor. in the previous tutorial, we have replaced the header, bottom, and sidebar code in this file with the code for loading the corresponding template. For a single article page, we need to put the article frame code page in a loop, but only go to a single page and only go through the loop once. Therefore, you can copy all the code in index. php, add, modify, and then add the code.

I. Article title
Find the article title:

 

Loreum ipsium massa cras phasellus

 

Do you still remember the code for getting the link and title in the previous tutorial?

">

 

II. article tags:

News, Products

 

Change

 

III. date
Change the date:

 

IV. number of comments

7 Comments

Change

 

5. content of the article.
Delete the image of the article and delete the following code:

 

/Images/610x150.gif "alt =" "/>

Delete all the article content, that is, the code between and, and replace it:

6. comment and return to the home page

<Back to Blog Discuss this post

 

Changed:

 

"Class =" button float "> <return to the homepage for comment

 

Okay, as mentioned earlier, the single-page content page of the article needs to be placed in a loop statement (in fact, we need to execute the the_post () function before the output article, this function will generate the article variable $ post ).
Add code to the end. effect:

 

 

 

Then in the code

 

 

. Add code in front of "to complete the effect:

No articles!

 

 

The operations here are similar to those on the home page, but only one article needs to be output here, so the addition of while does not matter much. Note that you must remember to add if, you have to have endif. if you have added while, you have to have endwhile.
Other syntaxes may not be used in this way. In fact, you can also use. For example:

 

 

OK. the single-page article creation method is complete.

 

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.