Enable Post and Page support for WordPress <! -More-> tag

Source: Internet
Author: User
When we use tags in wordpress to truncate an article, the content of the previous article is displayed on the homepage, category, tag, and archive pages, and in the Post) and Page, the label is ignored and the full text is displayed. WordPress

When we use When a tag truncates an article, the content of the article on the homepage, category, tag, and archive pages is displayed. In previous articles, while in Post and Page Label to display the full text.

This is of course reasonable. you cannot make the visitor stay in the abstract on your final article page.

However, topic developers often use a Page Template to list articles that meet the query conditions. For example, the following code returns all articles with a category ID of 3.

Reference content is as follows:




However, in this article list, the the_content () function will always output the full text, whether or not you have used the more tag in the article. Because WordPress only knows that this is a Page and needs to display the full text, it does not intelligently decide whether to support the more tag based on whether query_posts () is used or a new WP_Query object is created.

P.S: Sorry, I did not find this problem until today after I have made such a long wordpress topic. I personally prefer the "plain text summarization list" method. in the past, when I needed to create a document list, I used to automatically intercept document characters. However, for a project in progress, the customer needs to output the full html text, and then manually insert the more tag to truncation.

For a long time of nonsense, the solution is actually simple. please refer to the code (via weblogtoolscollection ):

Reference content is as follows:



Note: declare a global variable $ more before the_content () and set it to flase. If you want to return to the original status after the content is displayed, set the $ more variable to true later.

Address: http://paranimage.com/the-more-tag-on-a-wordpress-page/

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.