我想在<!--more-->
- 标记之前回复内容,而不是在250个字符后删除内容。主题不使用the_content
。
$content_of_post = get_post($get_post_id);
$content = $content_of_post->post_content;
$content = apply_filters('the_content', $content);
echo substr($content, 0, "250");
?>
答案 0 :(得分:1)
您可以通过strpos函数将文本截断到<!--more-->
,即:
substr($content, 0, strpos($content, '<!--more-->'));
试试这个:
<?php
$content_of_post = get_post($get_post_id);
$content = $content_of_post->post_content;
$content = substr($content, 0, strpos($content, '<!--more-->'));
echo apply_filters('the_content', $content);
?>