在带有"kursy“类别的帖子中,我需要在选项卡中显示内容。在任何其他文章中,只发布条目内容。我在if语句中插入html (带有一些php)有问题。
<?php
if ( in_category( 'kursy' )) {
echo " HTML with tabs "; //I need to insert the html here
} else {
echo get_the_content();
}
?>带有选项卡的我的html:
<div id="tabs">
<ul>
<li><a href="#tabs-1">About</a></li>
<li><a href="#tabs-2">Date</a></li>
<li><a href="#tabs-3">Gallery</a></li>
<li><a href="#tabs-4">Targets</a></li>
</ul>
<div id="tabs-1">
<?php echo get_the_content(); ?>
</div>
<div id="tabs-2">
<?php echo get_post_meta($post->ID, 'date', true); ?>
</div>
<div id="tabs-3">
<td><?php echo get_post_meta($post->ID, 'gallery', true); ?></td>
</div>
<div id="tabs-4">
<td><?php echo get_post_meta($post->ID, 'targets', true); ?></td>
</div>
</div>发布于 2014-08-01 12:41:07
使用此方法:
<?php
if ( in_category( 'kursy' )) { ?>
<div id="tabs">
<ul>
<li><a href="#tabs-1">About</a></li>
<li><a href="#tabs-2">Date</a></li>
<li><a href="#tabs-3">Gallery</a></li>
<li><a href="#tabs-4">Targets</a></li>
</ul>
<div id="tabs-1">
<?php echo get_the_content(); ?>
</div>
<div id="tabs-2">
<?php echo get_post_meta($post->ID, 'date', true); ?>
</div>
<div id="tabs-3">
<td><?php echo get_post_meta($post->ID, 'gallery', true); ?></td>
</div>
<div id="tabs-4">
<td><?php echo get_post_meta($post->ID, 'targets', true); ?></td>
</div>
</div>
<?php } else {
echo get_the_content();
}
?>https://stackoverflow.com/questions/25080462
复制相似问题