WordPress 사이트 내에서 각 카테고리에 하나의 게시물이있는 두 개의 카테고리를 만들었습니다. 나는 서로 다른 페이지에있는 각 카테고리 포스트에서 발췌하고 발췌하고있다.WordPress에서 2 단락을 발췌하려고 발췌
각 페이지에서 발췌 한 내용을 보여 주며 더 많은 링크를 수동으로 추가하고 있습니다.
<?php query_posts('cat=4&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">Read More</a>
<?php endwhile; ?>
다음 코드는 첫 번째 단락 뒤에 발췌 내용을 끝냅니다. 내가하고 싶은 무엇
function post_single_paragrapgh($text, $raw_excerpt) {
if(! $raw_excerpt) {
$content = apply_filters('the_content', get_the_content());
$text = substr($content, 0, strpos($content, '</p>') + 4);
}
return $text;
}
add_filter('wp_trim_excerpt', 'post_single_paragrapgh', 10, 2);
사실, 이미지 및 단락을 두 번째 단락 뒤에 리거나하도록 지시합니다.
게시물의 상단에 이미지가 있으면 이미지를 가져 오지만, 이미지의 다음 단락이나 텍스트의 단락 두 개를 원합니다. 하나 또는.
참조를 위해이 사이트를 사용했지만 오류 C1이 발생합니다. https://www.bybe.net/wordpress-the_excerpt-show-first-paragraph/
미리 감사드립니다.
[Question about strpos]의 가능한 중복. 문자열의 두 번째 발생을 얻는 방법?] (http://stackoverflow.com/questions/3126324/question-about-strpos-how-to-get-2nd-occurrence-of-the-string) – rnevius