dtsjq28482 2014-10-30 21:19
浏览 46
已采纳

HTML标记不在php if语句中显示

I have a WordPress theme with a brief summary, with css styling, at the top of a post. This is wrapped in an if statement to only display if there is a summary.

Using the code below, the summary text displays, but the surrounding HTML markup is not included in the page source.

<?php if (get_smry_text($post)) { ?>
<div class="summaryWrap">
    <div class="sumText">
        <p><?php get_smry_text($post); ?></p>
     </div>
 </div>
 <?php } ?>

Can anyone offer a suggestion as to why this might be?

  • 写回答

2条回答 默认 最新

  • dongmu3457 2014-10-30 21:23
    关注

    It is possible that get_smry_text() doesn't return any values.
    Instead it echoes the content directly. If you are using this function you can do something like this:

    <?php if ($smry = get_post_meta($post->ID, 'smry_text', true)) { ?>
    <div class="summaryWrap">
        <div class="sumText">
            <p><? echo $smry; ?></p>
         </div>
     </div>
     <?php } ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来