get_template_part 似乎要删除 h2 上的 class
get_template_part appears to be removing a class on h2
我正在开发一个自定义模板部分,其中包含带有 classes“sectionmarker”和“bodycontent”的 h2,如下所示:
<h2 class="sectionmarker bodycontent">Title</h2>
当我在页面上调用 get_template_part() 时,我得到的输出是:
<h2 class="bodycontent">Title</h2>
出于某种原因,它似乎不喜欢“sectionmarker”。我什至调换了两个 class 的顺序,像这样:
<h2 class="bodycontent sectionmarker">Title</h2>
我得到了相同的输出,只应用了正文内容 class。这是怎么回事?
完整模板内容:
<?php
$abstract=get_post_field('post_content',224);
$news=get_posts(array(
'post_type'=> 'news'
));
$newsdata=array();
foreach ($news as $n) {
$item=new stdClass();
$item->title=get_the_title($n->ID);
$item->date=get_the_date("",$n->ID);
$item->content=get_field('more_info',$n->ID);
array_push($newsdata,$item);
}
$newsdata_json=json_encode($newsdata);
?>
<script type="text/javascript">
console.log(<?php echo $newsdata_json ?>);
</script>
<?php
echo $abstract;
if(count($newsdata)>0){
?>
<h2 class="sectionmarker bodycontent" >News</h2>
<?php foreach ($newsdata as $newsitem) { ?>
<h4 class='datemarker bodycontent'><?php echo $newsitem->date ?></h4>
<p class='newstext bodycontent'><?php echo $newsitem->title ?></p>
<?php } } ?>
这是我正在拨打的电话(在 home.php):
get_template_part('custom-home-template',null,array());
没关系!我只记得我有一些 JavaScript 正在改变加载时的 h2 类。
我正在开发一个自定义模板部分,其中包含带有 classes“sectionmarker”和“bodycontent”的 h2,如下所示:
<h2 class="sectionmarker bodycontent">Title</h2>
当我在页面上调用 get_template_part() 时,我得到的输出是:
<h2 class="bodycontent">Title</h2>
出于某种原因,它似乎不喜欢“sectionmarker”。我什至调换了两个 class 的顺序,像这样:
<h2 class="bodycontent sectionmarker">Title</h2>
我得到了相同的输出,只应用了正文内容 class。这是怎么回事?
完整模板内容:
<?php
$abstract=get_post_field('post_content',224);
$news=get_posts(array(
'post_type'=> 'news'
));
$newsdata=array();
foreach ($news as $n) {
$item=new stdClass();
$item->title=get_the_title($n->ID);
$item->date=get_the_date("",$n->ID);
$item->content=get_field('more_info',$n->ID);
array_push($newsdata,$item);
}
$newsdata_json=json_encode($newsdata);
?>
<script type="text/javascript">
console.log(<?php echo $newsdata_json ?>);
</script>
<?php
echo $abstract;
if(count($newsdata)>0){
?>
<h2 class="sectionmarker bodycontent" >News</h2>
<?php foreach ($newsdata as $newsitem) { ?>
<h4 class='datemarker bodycontent'><?php echo $newsitem->date ?></h4>
<p class='newstext bodycontent'><?php echo $newsitem->title ?></p>
<?php } } ?>
这是我正在拨打的电话(在 home.php):
get_template_part('custom-home-template',null,array());
没关系!我只记得我有一些 JavaScript 正在改变加载时的 h2 类。