简体   繁体   English

如何将<span>标签</span>附加<span>到</span> <h1> <span>在Wordpress中前进</span>

[英]How can I append a <span> tag to a <h1> heading in Wordpress

I need to add a span tag to an h1 heading in wordpress. 我需要在wordpress的h1标题中添加一个span标签。 I tried writing in through the CMS but it renders the span tag as text. 我尝试通过CMS写入,但它将span标记呈现为文本。 The site's title is a name and I want to give different styles to the words. 该网站的标题是一个名称,我想给这些单词提供不同的样式。 Suggestions? 建议?

Following David Thomas 's advice I've written this: but it appends the span last and empty. 大卫·托马斯的意见,我已经写了这一点:但它追加span最后空。

<h1>
 <a href="<?php bloginfo('url'); ?>/">
  <?php             
    $completeName = bloginfo('name');
    $split = explode(" ",$completeName);
    echo $split[0]."<span>".$split[1]."</span>"
  ?>
 </a>
</h1>

You should be using get_bloginfo as Felipe suggested, but still pass in the 'name' parameter. 你应该像Felipe建议的那样使用get_bloginfo ,但仍传递'name'参数。

I was just working on the same code for the same reason and thought I should post for future visitors: 我只是出于相同的原因而在相同的代码上工作,并认为应该发布给将来的访问者:

<?php 
      $completeName = get_bloginfo('name');
      $nameParts = explode(" ", $completeName);
      echo '<span>'.$nameParts[0].'</span> '.$nameParts[1];
?>

Apply the style to the h1 instead. 将样式应用于h1

By the way, you probably want to edit the theme. 顺便说一下,您可能想要编辑主题。

What about: 关于什么:

  <? echo get_bloginfo('name', 'raw'); ?>

Can't test it for now, but here's the documentation about it: 目前尚无法测试,但是这里是有关它的文档:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM