Не выводится одиночная запись
есть сайт, на котором используется плагин Carbon fields. Была создан шаблон для рубрики "Блог"(id = 4), созданы две тестовые записи. При переходе по ссылке на запись не выводится контент, только print_r(130)
Шаблон рубрики Блог(category-blog.php) :
<?php
get_header();
get_template_part('template-parts/heder_page');
get_template_part('template-parts/blog');
get_template_part('template-parts/bread');
?>
<section class="blog-page">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="custom-heading">
<h2>Блог</h2>
</div>
</div>
</div>
<div class="row">
<?php
global $post;
$myposts = get_posts( [
'posts_per_page' => 6,
'category' => 4,
'post_type' => 'post',
] );
foreach( $myposts as $post ){
setup_postdata( $post );
?>
<div class="col-lg-6">
<div class="article">
<p class="title"><?php the_title(); ?></p>
<div class="content">
<?
the_excerpt();
?>
</div>
<a href="<?php the_permalink(); ?>" class="more">Читать полностью</a>
</div>
</div>
<?php
}
wp_reset_postdata();
?>
</div>
</div>
</section>
<?php
get_template_part('template-parts/form');
get_footer();
Шаблон записи single.php :
<?php
get_header();
get_template_part('template-parts/heder_page');
get_template_part('template-parts/bread');
if(in_category(4)) {
print_r(130);
if (have_posts()) :
while (have_posts()) : the_post();
the_title();
the_content();
endwhile;
endif;
} else {
get_template_part('template-parts/about_text');
get_template_part('template-parts/what_in');
get_template_part('template-parts/steps');
}
get_template_part('template-parts/form');
get_footer();
?>
Возможно влияет Carbon fields, есть файл по пути inc/carbon-fields/include-fields.php :
// Single Товар, Новость
add_action( 'carbon_fields_register_fields', 'type_post_services' );
function type_post_services() {
$Container = new Fields_Post_And_Hide_Template('post_meta', 'Настройки страницы', 'services', 'single.php');
$Container->heder_page();
$Container->about_text();
$Container->what_in();
$Container->steps();
return $Container;
}
Ответы (1 шт):
Автор решения: Anario
→ Ссылка
В single.php Нужно сразу выводить the_title(); the_content(); и остальные данные одиночной записи Повторный цикл для вывода оказался не нужен

