나는 뉴스를위한 워드 프레스 사이트를 가지고 있습니다. 일정한 양의 문자를 잘라내야합니다. 그것은 모두 substr()
을 통해 잘 작동하지만, x 문자보다 작 으면 열세가되어 다음 <li>
의 링크에 존재하지 않습니다. 은 $ 내용에substr을 통해 일정한 문자 수를 초과하면 텍스트를 자르지 못합니다.
echo '<li>', get_the_date('d.m.Y', $recent["ID"]), ' <a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li> ';
$post_id = $recent["ID"];
$post_content = get_post($post_id);
$content = $post_content->post_content;
echo mb_substr(do_shortcode($content), 0, 200 , "utf-8");
echo "...<br> <br>";
echo "</div>";
도움이 될 당신이해야 할 수도 있습니다 잘라내는 동안 HTML 태그를 유지하려면 어떻게 할 수 있는지에 대한 자습서가 있습니다. https://www.pjgalbraith.com/truncating-text-html-with-php/ – teeyo