页面内容未显示在 Wordpress 中 [英] Page Content Not Showing in Wordpress

查看:30
本文介绍了页面内容未显示在 Wordpress 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们对网站进行了一些更新,此后内容块不再显示在前端.这就是所谓的:

<?php get_template_part('content-block-loop');?>

这就是它所指的:

 'menu_order', 'order' => 'ASC', 'fields' => 'all');$terms = wp_get_post_terms( $post_object->ID, 'content_block_cat', $args );if(get_field('disable_wpautop',$post_object->ID)){remove_filter ('acf_the_content', 'wpautop');}包括(locate_template('partials/content-blocks/'.$terms[0]->slug.".php"));add_filter ('acf_the_content', 'wpautop');Endforeach;?><?php endif;?>

在partials/content-blocks/custom-content-block.php中有如下代码:

ID) ){$vertical_padding = get_field('vertical_padding',$post_object->ID);}if ( get_field('content_block_background_color',$post_object->ID) ){$background_color = get_field('content_block_background_color',$post_object->ID);}?><div class="panel <?php if( $vertical_padding != "none" ) { echo $vertical_padding; } ?> <?php echo $background_color; ?> relative-block"><div class="row"><div class="column small-12"><?php $custom_content_block_content = get_field('content',$post_object->ID);如果( $custom_content_block_content ){the_field('content',$post_object->ID);?>

我们也遇到了类似的问题,无法显示图像,并且能够更改 PHP 代码以使其正常工作.似乎它所说的(slugs 等)都被淘汰了.真的希望内容也有修复,但我看不到.TIA!

解决方案

我认为您需要使用 the_content() 来显示帖子内容.

function the_content( $more_link_text = null, $strip_teaser = false ) {$content = get_the_content( $more_link_text, $strip_teaser );/*** 过滤帖子内容.** @自 0.71 起** @param string $content 当前帖子的内容.*/$content = apply_filters('the_content', $content);$content = str_replace( ']]>', ']]>', $content );回声$内容;}

the_content() 模板标签获取帖子的内容,对其进行过滤,然后将其显示出来.这是每次通过 The Loop 的肉和土豆.

试试这个:

ID) ){$vertical_padding = get_field('vertical_padding',$post_object->ID);}if ( get_field('content_block_background_color',$post_object->ID) ){$background_color = get_field('content_block_background_color',$post_object->ID);}?><?php the_content();?><div class="panel <?php if( $vertical_padding != "none" ) { echo $vertical_padding; } ?> <?php echo $background_color; ?> relative-block"><div class="row"><div class="column small-12"><?php $custom_content_block_content = get_field('content',$post_object->ID);如果( $custom_content_block_content ){the_field('content',$post_object->ID);?>

WordPress 循环在您的页面上不活跃,通过包含 the_content() 应该可以解决您遇到的所有问题.

We did some updates to the site and since then the content blocks don't show in the frontend. This is what's being called:

<div class="page-content">
        <?php get_template_part('content-block-loop'); ?>
    </div>

And this is what it refers to:

<?php
$post_objects = get_field('page_content_blocks');
if( $post_objects ):
    foreach( $post_objects as $post_object):
        $args = array('orderby' => 'menu_order', 'order' => 'ASC', 'fields' => 'all');
        $terms = wp_get_post_terms( $post_object->ID, 'content_block_cat', $args );
        if( get_field('disable_wpautop',$post_object->ID) ){
          remove_filter ('acf_the_content', 'wpautop');
        }
        include( locate_template( 'partials/content-blocks/'.$terms[0]->slug.".php" ) );
        add_filter ('acf_the_content', 'wpautop');
    endforeach; ?>
<?php endif; ?>

And in partials/content-blocks/custom-content-block.php is has the following code:

<?php

$vertical_padding = "less-space";
$background_color = "white-bg";

if ( get_field('vertical_padding',$post_object->ID) ){
    $vertical_padding = get_field('vertical_padding',$post_object->ID);
}

if ( get_field('content_block_background_color',$post_object->ID) ){
    $background_color = get_field('content_block_background_color',$post_object->ID);
}

?>

<div class="panel <?php if( $vertical_padding != "none" ) { echo $vertical_padding; } ?> <?php echo $background_color; ?> relative-block">
    <div class="row">
        <div class="column small-12">
            <?php $custom_content_block_content = get_field('content',$post_object->ID);
            if( $custom_content_block_content ){
                the_field('content',$post_object->ID);
            } ?>
        </div>
    </div>
</div>

We also had a similar problem with the images not showing and was able to change the PHP code to make it work. It seems what it calls (slugs etc) has all got knocked out. Really hoping there's a fix for the content, too, but I can't see it. TIA!

解决方案

I think you will need to use the_content() to display post content.

function the_content( $more_link_text = null, $strip_teaser = false ) {
$content = get_the_content( $more_link_text, $strip_teaser );

/**
 * Filters the post content.
 *
 * @since 0.71
 *
 * @param string $content Content of the current post.
 */
$content = apply_filters( 'the_content', $content );
$content = str_replace( ']]>', ']]&gt;', $content );
echo $content;
}

The the_content() template tag fetches the content of the post, filters it, and then displays it. This is the meat and potatoes of each pass through The Loop.

Try this:

<?php

$vertical_padding = "less-space";
$background_color = "white-bg";

if ( get_field('vertical_padding',$post_object->ID) ){
  $vertical_padding = get_field('vertical_padding',$post_object->ID);
}

if ( get_field('content_block_background_color',$post_object->ID) ){
  $background_color = get_field('content_block_background_color',$post_object->ID);
}

?>
<?php the_content(); ?>

<div class="panel <?php if( $vertical_padding != "none" ) { echo $vertical_padding; } ?> <?php echo $background_color; ?> relative-block">
<div class="row">
    <div class="column small-12">
        <?php $custom_content_block_content = get_field('content',$post_object->ID);
        if( $custom_content_block_content ){
            the_field('content',$post_object->ID);
        } ?>

    </div>
</div>
</div>

The WordPress loop isn't active on your pages and by including the_content() should fix all the issues you are experiencing.

这篇关于页面内容未显示在 Wordpress 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
PHP最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆