【发布时间】:2015-09-27 19:13:30
【问题描述】:
我整天都在努力让它工作。我想根据帖子在 Wordpress 中的类别从单独的目录添加一些自定义 HTML,以保持干净。我似乎无法加载 html 文件。
相关代码为:
<div class="container">
<?php while ( have_posts() ) : the_post(); ?>
<div class="row clearfix">
<?php if (function_exists('breadcrumbs')) breadcrumbs(); ?>
<div class="title clearfix">
<a href="javascript:window.history.back();" class="back-list"></a>
<?php global $post; $category = get_the_category($post->ID); setPostViews($post->ID); ?>
<h1><?php echo $category[0]->name;?></h1>
</div>
<div class="detailBlock clearfix">
<h1><?php the_title()?></h1>
<div class="detail-inner">
<?php $featured_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full', true);
if($featured_img) {
echo "<div class='detail-img'><img src='$featured_img[0]' alt='".get_the_title()."'></div>";
echo $category[0]->ID ;
}
the_content();
?>
<?php
/* TEST CODE */
global $post; $category = get_the_category($post->ID);
if($category[0] == '6'){
include( get_template_directory_uri() '/call-to-actions/cta-weight-loss-fem.html');
}
?>
</div>
</div>
<?php endwhile;?>
</div>
【问题讨论】:
-
非常感谢亚历克斯!