【问题标题】:Html code inside php wordpress statementphp wordpress语句中的html代码
【发布时间】:2014-08-01 12:38:00
【问题描述】:

在“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>

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    使用这个方法:

    <?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(); 
    }
    ?>
    

    【讨论】:

      猜你喜欢
      • 2016-06-11
      • 2011-04-18
      • 1970-01-01
      • 2019-05-26
      • 2016-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-18
      相关资源
      最近更新 更多