Wie Sie Verhindern, dass WordPress aus den Stripping-HTML-Tags im Excerpt

Ich bin mit wp_trim_words zu trimmen einige Ausschnitte auf meiner homepage. Es funktioniert einwandfrei außer das es Strippen die HTML-tags aus der Auszüge. Ich muss in der Lage sein, um bestimmte Teile des Zitates Fett (mit <strong>). Nach den Anweisungen hier, ich habe versucht, das entfernen der wp_trim_words Funktion und ersetzen Sie Sie durch eine neue mit dem folgenden code ersetzt $text = wp_strip_all_tags( $text ); von der ursprünglichen WP-Funktion mit $text = strip_tags($text, '<strong>',);. Aber das bricht der Website. Was mache ich falsch?

    //Remove Reverie Trim Words
function remove_trim_words() {
    remove_filter('get_the_excerpt', 'wp_trim_words');
    add_filter('get_the_excerpt', 'oakwood_trim_words');
}

//Replace Reverie Trim Words
function oakwood_trim_words( $text, $num_words = 55, $more = null ) {
    if ( null === $more )
        $more = __( '&hellip;' );
    $original_text = $text;
    $text = strip_tags($text, '<strong>',);
    /* translators: If your word count is based on single characters (East Asian characters),
       enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
    if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
        $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
        preg_match_all( '/./u', $text, $words_array );
        $words_array = array_slice( $words_array[0], 0, $num_words + 1 );
        $sep = '';
    } else {
        $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
        $sep = ' ';
    }
    if ( count( $words_array ) > $num_words ) {
        array_pop( $words_array );
        $text = implode( $sep, $words_array );
        $text = $text . $more;
    } else {
        $text = implode( $sep, $words_array );
    }
    /**
     * Filter the text content after words have been trimmed.
     *
     * @since 3.3.0
     *
     * @param string $text          The trimmed text.
     * @param int    $num_words     The number of words to trim the text to. Default 5.
     * @param string $more          An optional string to append to the end of the trimmed text, e.g. &hellip;.
     * @param string $original_text The text before it was trimmed.
     */
    return apply_filters( 'oakwood_trim_words', $text, $num_words, $more, $original_text );
}
Wie die Website brechen?
Es zeigt nur eine komplett leere weiße Seite an. Keine Inhalte bei allen.

InformationsquelleAutor mcography | 2014-06-10

Schreibe einen Kommentar