Home > CMS Tutorial > WordPress > body text

How to make wordpress only display the first 3 lines of an article

Release: 2019-07-15 09:04:19
Original
2819 people have browsed it

How to make wordpress only display the first 3 lines of an article

#In WordPress, you can use the more tag to display only the first three lines of an article. As long as you insert the more tag after the third line, you can realize that only the first three lines of the article will be displayed when the web page is displayed. Three lines.

I believe that friends who have been in contact with WordPress are familiar with the "more" tag. When the mouse slides to the toolbar as shown below in the edit box, there will be an "Insert more tag" hint. But will you use it? It is estimated that many of my friends have never encountered this label.

How to make wordpress only display the first 3 lines of an article

The role of the more tag:

In fact, the more tag can be used to control the display of the article summary content. When the content of all articles is displayed as a single article (read the full text), when the content of non-single articles (categories, tags, article lists, etc.) is displayed as the content above the more tag (abstract), the user clicks on the article title to enter. Read the full text. In this way, you can also control the style of the article list, making the article list more neat and beautiful. As shown in the figure below:

How to make wordpress only display the first 3 lines of an article

Usage method:

Method 1:

In the visual interface of the wordpress article editor, click Just click the "Insert more tag" icon as shown in the picture when setting the summary. (If you use a third-party editor, the icon may be different, but the operation method is the same)

How to make wordpress only display the first 3 lines of an article

Method 2: Implementation through code

In fact, method 1 is also through code What is achieved is just a visual operation. Click the text next to the editor (or other HTML code editing mode) to see that the following code is inserted into the source code.

<!--more-->
Copy after login

How to make wordpress only display the first 3 lines of an article

When we read the content of articles on some websites, we must have discovered that there are words such as "Read the full text" and "View more" next to the abstract, and also style it. settings, such as displaying in picture form, etc. This requires an in-depth understanding of the more tag, as well as html and css code, which is also very simple. Here I will talk about some basic functions and usages. For detailed information, there are many related resources on the Internet, which can be searched and consulted.

For more wordpress related technical articles, please visit the wordpress tutorial column to learn!

The above is the detailed content of How to make wordpress only display the first 3 lines of an article. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!