简体   繁体   English

如何将文本添加到html或php文件的meta中?

[英]How do I add text to my entry-meta to html or my php file?

I'm trying to add · Product 1 text to my entry-meta but I don't know how to add it to html or my php file. 我正在尝试将·产品1文本添加到我的entry-meta但是我不知道如何将其添加到html或php文件中。 This entry-meta goes under the post title and goes on each post so I don't know also how to make the 1 in Product 1 change for each post. 此条entry-meta位于帖子标题下,并且在每个帖子中都有,因此我也不知道如何为每个帖子更改产品1中的1。

This is what I want it to say: 这就是我想说的:

By Kyle Boas · Follow: Twitter 凯尔·博阿斯(Kyle Boas)·关注:Twitter

September 21, 2014 · Product 1 2014年9月21日·产品1

but it currently says: 但目前它说:

By Kyle Boas · Follow: Twitter 凯尔·博阿斯(Kyle Boas)·关注:Twitter

September 21, 2014 2014年9月21日

Here is the code of the entry-header : 这是entry-header的代码:

   <p class="entry-meta">
     <span class="author_wrap">By <span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person">
     <span class="entry-author-name" itemprop="name">Kyle Boas</span></span></span> 
     · 
     <span class="follow_links">Follow: <a href="http://twitter.com/boasish" target="_blank">Twitter</a></span> 
     <span class="date_comment"><time class="entry-time" itemprop="datePublished" datetime="2014-09-21T19:42:35+00:00">September 21, 2014</time></span></p></header>

You can see it for yourself on my website: http://boasish.com 您可以在我的网站上看到它: http : //boasish.com

there is no php code to output anything? 没有PHP代码输出任何东西?

you need to add some php code to output that .... 您需要添加一些php代码以输出该....

for example change: 例如更改:

<span class="date_comment"><time class="entry-time" itemprop="datePublished" datetime="2014-09-21T19:42:35+00:00">September 21, 2014</time></span>

to

<span class="date_comment"><time class="entry-time" itemprop="datePublished" datetime="2014-09-21T19:42:35+00:00">September 21, 2014</time><? echo "Product " . $x; ?></span>

where $x is the number of the product you want to output ... 其中$ x是要输出的产品编号...

To show a counter of products you'd need a variable; 要显示产品计数器,您需要一个变量; lets say $i . 假设$i

First it would be good to initialize the variable $i , which must be done before the post loop . 首先,最好初始化变量$i ,该变量必须在post循环之前完成。

$x = 0;

Then, you increment the variable and show it: 然后,增加变量并显示它:

<p class="entry-meta">
    <span class="author_wrap">By <span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person">
    <span class="entry-author-name" itemprop="name">Kyle Boas</span></span></span> 
    · 
    <span class="class-for-product">Product <?php echo ++$i; ?></span>

    <span class="follow_links">Follow: <a href="http://twitter.com/boasish" target="_blank">Twitter</a></span> 
    <span class="date_comment"><time class="entry-time" itemprop="datePublished" datetime="2014-09-21T19:42:35+00:00">September 21, 2014</time></span>
</p>

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

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