【问题标题】:Proper way to add <h1> tag to a wordpress function将 <h1> 标签添加到 wordpress 函数的正确方法
【发布时间】:2011-03-02 16:25:49
【问题描述】:

我正在自定义一个 Wordpress 插件,但似乎无法弄清楚如何正确地将 &lt;h1&gt; 标签添加到它在我的帖子标题中引入的部分。我每次尝试都会遇到错误。

代码如下:

<?php query_posts('cat=3'); ?>

<?php 

    $category = get_option('wpns_category');

    $n_slices = get_option('wpns_slices');

?>

<?php if( have_posts() ) : while( have_posts() ) : the_post(); ?>

<?php if ( has_post_thumbnail() ) {
            echo '<a href="';
            the_permalink();
            echo '">';
the_post_thumbnail('slider-image', array( 'alt' =>
get_the_title(), 'title' => get_the_title() . "<br /><br /> <span>" . get_the_excerpt() .
"</span>"));
            echo '</a>'; } ?>

<?php endwhile; ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>

我尝试过例如&lt;h1&gt;get_the_title(), 'title' =&gt;&lt;/h1&gt;,但显然这是不正确的。有什么建议吗?

【问题讨论】:

    标签: php wordpress tags


    【解决方案1】:
      'title' => "<h1>" . get_the_title() . "</h1><br/>.....
    

    【讨论】:

    • @Orbit:成功了!就我所知,在引号中添加&lt;h1&gt; 之后添加. 意味着“和”?如“这将是一个标题,然后获取标题然后创建一个换行符?”
    • @themerlinproject:我不确定它为什么被否决,它奏效了。
    • 不要在

      标记之后放置

    • 那是在原始代码中,只是包含它以显示在哪里放置额外的标头标签,不过感谢您。
    猜你喜欢
    • 1970-01-01
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-23
    • 2011-01-28
    • 1970-01-01
    • 2020-10-10
    相关资源
    最近更新 更多