我正在开发Onepress的儿童主题。我需要在主标签内的容器div中显示所有帖子。我在代码中做到了, 但是, 一些帖子在浏览器的main标签之外呈现。它破坏了布局。任何帮助将深表感谢!
这是我文件中的代码:
<
div id="content" class="site-content">
<
?php onepress_breadcrumb();
?>
<
div id="content-inside" class="container">
<
div id="primary" class="content-area">
<
main class="site-main" role="main">
<
div class="container">
<
?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
?>
<
div class="container">
<
?php get_template_part( 'template-parts/content', 'custom' );
?>
<
/div>
<
?php endwhile;
the_posts_navigation();
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
<
/div>
<
/main>
<
!-- #main -->
<
/div>
<
!-- #primary -->
<
/div>
<
!--#content-inside -->
<
/div>
<
!-- #content -->
自定义模板文件中的代码:
<
article class="row entry-article col-sm-12 col-md-12 w-100" id="post-<
?php the_ID();
?>
" <
?php post_class( array('list-article', 'clearfix') );
?>
>
<
div class="col-sm-12 col-md-3 thumb-custom-container">
<
a href="http://www.srcmini.com/<
?php echo esc_url( get_permalink() );
?>">
<
?php
if ( has_post_thumbnail( ) ) {
the_post_thumbnail( 'onepress-blog-medium' );
} else {
echo '<
img class="thumb-custom" src="'. get_template_directory_uri() . '/assets/images/placholder2.png' .'">
';
}
?>
<
/a>
<
/div>
<
div class="col-sm-12 col-md-6">
<
div class="row">
<
div class="col-sm-12">
<
header class="entry-header col-sm-12">
<
?php /* the_title( sprintf( '<
p>
<
a href="http://www.srcmini.com/%s" rel="bookmark">
', esc_url( get_permalink() ) ), '<
/a>
<
/p>
' );
*/ ?>
<
?php
$post_id = get_the_ID();
echo '<
h2 class="entry-price">
R$ ' . get_post_meta($post_id, 'real_state_price', true) . '<
/h2>
';
$post_id = get_the_ID();
echo '<
small class="entry-features">
'
. get_post_meta($post_id, 'real_state_size', true) . ' m2, Square '
. get_post_meta($post_id, 'real_state_square', true) . ', Number '
. get_post_meta($post_id, 'real_state_number', true)
. '<
/small>
';
?>
<
/header>
<
!-- .entry-header -->
<
div class="col-sm-12 entry-excerpt">
<
?php
the_excerpt();
?>
<
/div>
<
/div>
<
div class="col-sm-12 entry-link">
<
button class="btn entry-btn-details" href="http://www.srcmini.com/<
?php echo esc_url( get_permalink($post_id) );
?>">
+<
/button>
<
span>
<
a class="entry-read-more" href="http://www.srcmini.com/<
?php echo esc_url( get_permalink($post_id) );
?>">
Read More
<
/a>
<
/span>
<
/div>
<
/div>
<
/div>
<
!-- PICTURE FROM CATEGORIE IMAGES PLUGIN -->
<
div class="col-sm-12 col-md-3">
<
div class="col-sm-12 entry-residencial">
<
a href="http://www.srcmini.com/<
?php echo esc_url( get_permalink() );
?>">
<
?php
$residencial_terms = get_the_terms($post_id, 'residencials');
foreach ($residencial_terms as $term) : ?>
<
img src="http://www.srcmini.com/<
?php echo z_taxonomy_image_url($term->
term_id);
?>" />
<
?php endforeach;
?>
<
/a>
<
/div>
<
div class="col-sm-12">
<
?php
// Teste para identificar a cidade e chamar o modal de contato correspondente
$cities_terms = get_the_terms($post_id, 'city');
if (!empty($cities_terms)) :
if (is_array($cities_terms)) :
foreach ($cities_terms as $term) :
$term_name = $term->
name;
$city = $term_name == 'City01' ? 'firstModal' : 'secondModal';
endforeach;
else :
$city = $term;
endif;
else :
$city = 'generalModal';
endif;
?>
<
button type="button" class="btn entry-btn" data-toggle="modal" data-target="#<
?php echo $city;
?>
">
Contact
<
/button>
<
/div>
<
/div>
<
/div>
<
!-- entry content -->
这是在浏览器中呈现的代码:
<
div id="content" class="site-content">
<
?php onepress_breadcrumb();
?>
<
div id="content-inside" class="container">
<
div id="primary" class="content-area">
<
main class="site-main search-page" role="main">
<
div class="container">
SOME POSTS HERE<
/div>
<
/main>
<
!-- #main -->
<
!-- OTHER POSTS ARE INCORRECTLY HERE -->
<
div class="container">
INCORRECTLY PLACED POSTS<
/div>
<
!-- incorrectly placed posts -->
<
/div>
<
!-- #primary -->
<
/div>
<
!--#content-inside -->
<
/div>
<
!-- #content -->
那么, 有人知道如何解决此错误吗?感谢大伙们!
#1看起来你的代码中包含一些无效的HTML。
【WordPress从循环所在的HTML标签中删除了一些文章。为什么?】到目前为止, 我可以发现这种不一致:
<
div class="col-sm-12 entry-excerpt">
<
?php
the_excerpt();
?>
<
/div>
<
/div>
推荐阅读
- WordPress is_single()在自定义WP_Query中始终返回true
- 当在functions.php文件中调用WordPress时,WordPress无法从数据库获取值
- WordPress在wp_users中插入新用户
- WordPress的是否可以使用钩子在帖子标题的标记之后插入标记()
- WordPress(在两个菜单项之间插入char)
- WordPress独立functions.php
- WordPress图片在iOS上显示不佳
- WordPress(我自动在wp-content/themes/mytheme/function.php中添加了一个代码)
- WordPress iframe中心