【问题标题】:Display WordPress full content instead post excerpt显示 WordPress 完整内容,而不是发布摘录
【发布时间】:2014-08-26 19:03:50
【问题描述】:

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

我发现了类似的东西

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 完整内容而不是发布摘录。

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    使用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')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-30
      • 1970-01-01
      • 1970-01-01
      • 2012-04-29
      • 1970-01-01
      相关资源
      最近更新 更多