Tips on how to make two Excerpts within each wordpress article

Asked

Viewed 54 times

0

I need tips on how to create Excerpts (summaries) in Wordpress, I have some knowledge on the platform but still very limited and do not know where to start.

There are two summaries within each blog article, a default form. Where the characters to be displayed will be limited. I’ve looked for information in several places and I haven’t found.

In the same way as the image below. With the text summarized in some 6 lines and "SEE MORE"

I don’t have code yet because I don’t really know where to start. I need tips, information, links, anything that gives me a "north".

Exemplo do link "ver mais"

  • It’s not what you marked. I was reviewing the content. But I’m very grateful for the help. No bootstrap , I would like the administrative panel , had two fields , where I write the articles. When it is published, the characters of the content are limited. Default is the number of lines to show to users. In my , it will be 6 lines. Similarly to Udemy’s layout.

  • I withdrew the vote. I understood. It will show the first 6 lines, but if there are only 3 lines? And the internal content, can have one with 8 lines and another with 80 lines?

  • Yes, no matter how many lines you will have in the internal content. If it has less than 6 lines , the content is shown without the "See more" function, but if it has more than 6 lines , it will have the "See more" it can have 7 lines , the content will be limited.

1 answer

0


Here is a simple template that can help you. If your text has less than 6 lines just vc remove the "Read more"

The technique is to use a Label with a for to the checkbox that is hidden outside the .box. When that checkbox is marked by clicking on label to .box increases and shows the whole content. Like .box is tall max-height it will always adjust with your content, unless it is more than 1000px high, which is something very unlikely, but if you need tb just change this value...

See it working so you understand better. I left the comments in the code to help you

html, body {
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
}
.box {
	border: 1px solid #000;
	display: flex;
	flex-direction: column;
	margin: 1rem;
/* altura inicial do box, mude aqui o suficiente para mostrar quanto quiser do conteúdo inicial */
	max-height: 200px;
	position: relative;
	padding: 0 1rem 2rem;
	box-sizing: border-box;
	overflow: hidden;
	transition: max-height 500ms;
}
input:checked + .box {
	max-height: 1000px;
	/* hake para fazer o box crescer, o tamanho máximo dele é 1000px ou menosse o conteúdo for menor */
}
.box > label {
	cursor: pointer;
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	margin-left: 1rem;
	height: 3rem;
	line-height: 3rem;
	background-image: linear-gradient(to bottom, transparent, #fff 25%);
	color: red;
}
.box > label:hover {
	text-decoration: underline;
}
#ler {
	display: none; 
	/* remove o checkbox da tela */
}
<!-- quando o input for checado o box cresce -->
<input type="checkbox" name="" id="ler" hidden>
<div class="box">
  <div>
    <p>1 Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste, aut!</p>
    <p>2 Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste, aut!</p>
    <p>3 Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste, aut!</p>
    <p>4 Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste, aut!</p>
    <p>5 Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste, aut!</p>
    <p>6 Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste, aut!</p>
    <p>7 Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste, aut!</p>
    <p>8 Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste, aut!</p>
  </div>
  <!-- label para checar o checkbox quando for clicada -->
  <label for="ler">leia mais</label>
</div>

  • Hugo , I don’t know how to thank you. Thank you very much. From my heart.

  • @Gmsan How nice young man! I’m glad to have helped. If you think your problem has been solved consider marking the answer as Accepted . So it is not pending on the site as unresolved question.

  • @Gmsan was missing something? I thought it worked there...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.