为什么这一页上的段落没有断开?

时间:2015-04-04 作者:T.rev

This page 是使用“我的主题”中包含的最近发布的快捷码创建的。它不显示我在编辑器中添加的段落分隔符,我希望这样。如何获得显示段落分隔符的快捷码?

这是编译最近帖子列表的代码:

if (!function_exists(\'mo_get_thumbnail_post_list\')) {
function mo_get_thumbnail_post_list($args) {

    /* Set the default arguments. */
    $defaults = array(
        \'loop\' => null,
        \'image_size\' => \'small\',
        \'style\' => null,
        \'show_meta\' => false,
        \'excerpt_count\' => 120,
        \'hide_thumbnail\' => false
    );

    /* Merge the input arguments and the defaults. */
    $args = wp_parse_args($args, $defaults);

    /* Extract the array to allow easy use of variables. */
    extract($args);

    if ($loop->have_posts()):

        $css_class = $image_size . \'-size\';

        $image_size = mo_get_post_image_size($image_size);

        $style = ($style ? \' \' . $style : \'\');

        $output = \'<ul class="post-list\' . $style . \' \' . $css_class . \'">\';

        $hide_thumbnail = mo_to_boolean($hide_thumbnail);

        $show_meta = mo_to_boolean($show_meta);

        while ($loop->have_posts()) : $loop->the_post();

            $output .= \'<li>\';

            $thumbnail_exists = false;

            $output .= "\\n" . \'<div class="\' . join(\' \', get_post_class()) . \'">\' . "\\n"; // Removed id="post-\'.get_the_ID() to help avoid duplicate IDs validation error in the page

            if (!$hide_thumbnail) {
                $thumbnail_url = mo_get_thumbnail(array(\'image_size\' => $image_size));
                if (!empty($thumbnail_url)) {
                    $thumbnail_exists = true;
                    $output .= $thumbnail_url;
                }
            }

            $output .= "\\n" . \'<div class="entry-text-wrap \' . ($thumbnail_exists ? \'\' : \'nothumbnail\') . \'">\';

            $output .= "\\n" . the_title(\'<div class="entry-title"><h2><a title="\' . the_title_attribute(\'echo=0\') . \'" rel="bookmark">\', \'</a></h2></div>\', false);

            if ($show_meta) {
                $output .= \'<div class="byline">\' . mo_entry_published() . mo_entry_comments_number() . \'</div>\';
            }

            if ($excerpt_count != 0) {

                $output .= "\\n" . \'<div class="entry-summary">\';

                $output .= get_the_content();

                $output .= "\\n" . \'</div><!-- entry-summary -->\';
            }

            $output .= "\\n" . \'</div><!-- entry-text-wrap -->\';

            $output .= "\\n" . \'</div><!-- .hentry -->\';

            $output .= \'</li>\';

        endwhile;

        $output .= \'</ul>\';

    endif;

    wp_reset_postdata();

    return $output;
}
}
我已经就此联系了主题创建者,他们对此事没有太大帮助。

2 个回复
最合适的回答,由SO网友:Pieter Goosen 整理而成

get_the_content() 返回未过滤的内容,并使用无法使用的快捷码the_content() 返回筛选后的内容,因为您无法在短代码内进行回显。你最好的选择是申请the_content 筛选到get_the_content(), 类似于:

apply_filters( \'the_content\', get_the_content() );
编辑确切用法,替换

$output .= get_the_content();
使用

$output .= apply_filters( \'the_content\', get_the_content() );

SO网友:T.rev

找到解决方案here:

function get_the_content_with_formatting ($more_link_text = \'(more...)\', $stripteaser = 0, $more_file = \'\') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters(\'the_content\', $content);
$content = str_replace(\']]>\', \']]&gt;\', $content);
return $content;
}

结束

相关推荐

尝试修改插件中的自定义搜索功能以搜索POSTMETA表中的关键字以及POSTS表

我正在尝试修改一个插件,该插件搜索posts表,并让它也搜索POSTETA表中的meta\\u值。原始代码为:if (!($index_page = $wpdb->get_row(\"SELECT ID AS id, post_name AS slug FROM {$wpdb->posts} WHERE (post_content LIKE \'%[\" . W2DC_MAIN_SHORTCODE . \"]%\' OR post_content LIKE \'%[\" . W2DC_MAIN