显示WordPress完整内容而不是发布摘录

时间:2014-08-26 19:03:50

标签: php wordpress

我想显示完整内容而不是帖子摘录。我不想修改主题。我只想制作一个插件,我将放置文件。

我找到了类似的东西

function narga_excerpts($content = false) {
    # If is the home page, an archive, or search results
    if(is_front_page() || is_archive() || is_search()) :
        global $post;
    $content = $post->post_excerpt;
    $content = strip_shortcodes($content);
    $content = str_replace(']]>', ']]>', $content);
    $content = strip_tags($content);
    # If an excerpt is set in the Optional Excerpt box
    if($content) :
        $content = apply_filters('the_excerpt', $content);
    # If no excerpt is set
    else :
        $content = $post->post_content;
    $excerpt_length = 50;
    $words = explode(' ', $content, $excerpt_length + 1);
    if(count($words) > $excerpt_length) :
        array_pop($words);
    array_push($words, '...<p><a class="more-link" href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '">  ' . __( 'Read more &#187;', 'narga' ) . ' </a></p>');
    $content = implode(' ', $words);
endif;
$content = '<p>' . $content . '</p>';
endif;
endif;

return $content;
    }

add_filter('the_content', 'narga_excerpts')

但它完全不同。代码修改the_content以显示the_excerpts。如何更改代码以显示WordPress完整内容而不是发布摘录。

1 个答案:

答案 0 :(得分:0)

使用the_content()将显示帖子的完整内容。

将功能更改为此功能

function narga_excerpts($content = false) 
{
    # If is the home page, an archive, or search results
    if(is_front_page() || is_archive() || is_search()) :
        global $post;
    $content = $post->post_content;
    endif;

    return $content;
}

add_filter('the_content', 'narga_excerpts')