我有这个摘录功能
<?php
function pietergoosen_get_the_content_limit_custom_allowedtags() {
// Add custom tags to this string
return \'<head>,<title>,<base>,<link>,<meta>,<style>,<script>,<noscript>,<body>,<section>,<nav>,
<article>,<aside>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>,<header>,<footer>,<address>,<main>,<p>,<hr>,
<pre>,<blockquote>,<ol>,<ul>,<li>,<dl>,<dt>,<dd>,<figure>,<figcaption>,<div>,<a>,<em>,<strong>,
<small>,<s>,<cite>,<q>,<dfn>,<abbr>,<data>,<time>,<code>,<var>,<samp>,<kbd>,<sub>,<sup>,<i>,<b>,
<u>,<mark>,<ruby>,<rt>,<rp>,<bdi>,<bdo>,<span>,<br>,<wbr>,<ins>,<del>,<img>,<iframe>,<embed>,
<object>,<param>,<video> ,<audio>,<source>,<track>,<canvas>,<map>,<area>,<svg>,<math>,<table>,
<caption>,<colgroup>,<col>,<tbody>,<thead>,<tfoot>,<tr>,<td>,<th>,<form>,<fieldset>,<legend>,<label>,
<input>,<button>,<select>,<datalist>,<optgroup>,<option>,<textarea>,<keygen>,<output>,<progress>,<meter>,
<details>,<summary>,<menuitem>,<menu>\';
}
function pietergoosen_custom_wp_trim_excerpt($text) {
global $post;
$raw_excerpt = $text;
if ( \'\' == $text ) {
$text = get_the_content(\'\');
$text = strip_shortcodes( $text );
$text = apply_filters(\'the_content\', $text);
$text = str_replace(\']]>\', \']]>\', $text);
//Add the allowed HTML tags separated by a comma.
$text = strip_tags($text, pietergoosen_get_the_content_limit_custom_allowedtags());
//Set the excerpt word count and only break after sentence is complete.
$excerpt_word_count = 75;
$excerpt_end = \' <a href="\'. esc_url( get_permalink() ) . \'">\' . \'…\' . __( \'Read more about this article <span class="meta-nav">→</span>\', \'pietergoosen\' ) . \'</a>\';
$tokens = array();
$out = \'\';
$count = 0;
// Divide the string into tokens; HTML tags, or words, followed by any whitespace
preg_match_all(\'/(<[^>]+>|[^<>\\s]+)\\s*/u\', $text, $tokens);
foreach ($tokens[0] as $token) {
if ($count >= $excerpt_word_count && preg_match(\'/[\\?\\.\\!]\\s*$/uS\', $token)) {
// Limit reached, continue until ? . or ! occur at the end
$out .= trim($token);
break;
}
// Add words to complete sentence
$count++;
// Append what\'s left of the token
$out .= $token;
}
$text = force_balance_tags($out);
$text = $text . $excerpt_end;
}
return apply_filters(\'wp_trim_excerpt\', $text, $raw_excerpt);
}
remove_filter(\'get_the_excerpt\', \'wp_trim_excerpt\');
add_filter(\'get_the_excerpt\', \'pietergoosen_custom_wp_trim_excerpt\');
?>
一切都按预期进行,除了
Read more about this article...
出现在摘录后的单独段落中,而不是出现在默认摘录的最后一个单词旁边。在google中,我可以看到wordpress添加了
<p>
标记周围的
Read more about this article
我怎样才能解决这个问题。