I bring a preview of the text of the article in this form:

index.php:

<div class="post__content"> ... <?php mytheme_excerpt(70); ?> ... </div> 

function.php:

  /** Replaces "[...]" (appended to automatically generated excerpts) with ... and a 'Continue reading' link. */ function mytheme_excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); array_pop($excerpt); $excerpt = implode(" ",$excerpt)."<a href='" .get_permalink($post->ID) ." ' class='link'>...</a>"; echo $excerpt; } 

Through the admin I enter the text of the article.

Expectations:

 <div class="post__content"> ... <p> Lorem ipsum .... </p> ... </div> 

Reality:

 <div class="post__content"> ... Lorem ipsum .... ... </div> 

The <p> </p> tag is missing.

Question: how to programmatically make it so that when you add the text of the article, it turns into a <p></p> paragraph.

    1 answer 1

     /** Replaces "[...]" (appended to automatically generated excerpts) with ... and a 'Continue reading' link. */ function mytheme_excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); array_pop($excerpt); $excerpt = "<p>".implode(" ",$excerpt)."<a href='" .get_permalink($post->ID) ." ' class='link'>...</a></p>"; echo $excerpt; } 
    • So all the previews are wrapped in a paragraph, and if I have 2-3 small paragraphs in the preview that fit into the preview. Those. I need for example this: <p> lfjhgdfhjghdj </p> <p> lfjhgdfhjghdj </p> < href="#" class="more" > ... </a> - HamSter
    • Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky
    • And these paragraphs are in the text of the article entered through the admin panel? Or should they be added? - KAGG Design