自定义输出的内容的格式,自定义输出的p标签

$about_content = get_post_field('post_content', $about_page);

// Remove Gutenberg block comments
$content = preg_replace('/<!--\s*wp:.*?-->/s', '', $about_content);
$content = preg_replace('/<!--\s*\/wp:.*?-->/s', '', $content);

// Clean and trim
$content = trim($content);

// Trim to 1500 characters
$trimmed_content = mb_substr($content, 0, 1500);

// Apply wpautop and convert p tags to br
$formatted_content = wpautop($trimmed_content);
$br_content = str_replace('<p>', '', $formatted_content);
$br_content = str_replace('</p>', '<br>', $br_content);

// Remove any empty <br> tags at the beginning
$br_content = preg_replace('/^(<br\s*\/?>\s*)+/', '', $br_content);

echo $br_content;
×
自定义输出的内容的格式,自定义输出的p标签

自定义输出的内容的格式,自定义输出的p标签

$about_content = get...