【问题标题】:Why is the button not appearing?为什么按钮没有出现?
【发布时间】:2020-11-21 18:23:13
【问题描述】:

我是编码的菜鸟。

这是 content.php 中主题附带的内容:

<div class="ct-button">
                    <a href="<?php echo get_the_permalink(); ?>" class="btn"
                       <?php esc_html_e( 'read more' , 'untold' ); ?>> </a>

在我开始在 php 文件中添加样式之前,它工作正常。现在,按钮根本没有出现,即使我已经消除了我的样式添加。有什么遗漏吗?

【问题讨论】:

  • 因为您的a 标记中有错误。正确的应该是&lt;a href="&lt;?php echo get_the_permalink(); ?&gt;" class="btn"&gt;&lt;?php esc_html_e( 'read more' , 'untold' ); ?&gt; &lt;/a&gt;
  • 为了补充@PavelJanicek 所说的内容,您通过将锚文本包含在开始标记中而不是将其放在在开始和结束标记之间,从而错放了锚文本。跨度>

标签: php html button


【解决方案1】:

发生这种情况是因为您将代码 &lt;?php esc_html_e('read more', 'untold'); ?&gt; 放在了开始标记内。只需从标签中提取该部分,如下所示:

<a href="<?=get_the_permalink()?>" class="btn">
   <?php esc_html_e('read more', 'untold'); ?>
</a>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    相关资源
    最近更新 更多