如何在 Wordpress 中显示帖子标题? [英] How to display post title in Wordpress?
问题描述
我想在以下 javascript 代码中生成 wordpress 帖子标题:我将此代码放在我的 wordpress 帖子的内容下.
I'd like to generate the wordpress post title in the following javascript code: I'm placing this code under the content in my wordpress posts.
<script charset="utf-8" type="text/javascript">
document.write('\x3Cscript type="text/javascript" charset="utf-8" src="http://adn.ebay.com/cb?programId=1&campId=5337203820&toolId=10026&customId=posttop&keyword=**POST-TITLE**&width=728&height=90&font=1&textColor=000000&linkColor=0000AA&arrowColor=8BBC01&color1=709AEE&color2=[COLORTWO]&format=ImageLink&contentType=TEXT_AND_IMAGE&enableSearch=y&usePopularSearches=n&freeShipping=n&topRatedSeller=y&itemsWithPayPal=n&descriptionSearch=n&showKwCatLink=n&excludeCatId=&excludeKeyword=&catId=177913%2C179767%2C1059&disWithin=200&ctx=n&autoscroll=n&flashEnabled=' + isFlashEnabled + '&pageTitle=' + _epn__pageTitle + '&cachebuster=' + (Math.floor(Math.random() * 10000000 )) + '">\x3C/script>' );
脚本的 keyword= 部分是我需要生成 wordpress 帖子标题的地方.我正在尝试 keyword="<?php single_post_title(); ?>"
但它没有生成 wordpress 帖子标题......不确定我是否在正确的轨道上.
The keyword= part of the script is where I need to generate the wordpress post title. I was trying keyword="<?php single_post_title(); ?>"
but it doesn't generate the wordpress post title... not sure if I'm on the right track or not.
任何帮助将不胜感激.请记住我是新手.如果我忘记提及某事,请询问.我会尽快回复.
Any help would be appreciated. Please remember I'm a newbie. If I forgot to mention something please ask. I'll be quick to respond.
非常感谢!
推荐答案
在你的循环中查看 if ( have_posts() )
和 while
,在 while
语句.
inside your loop see if ( have_posts() )
and while
, use this inside the while
statement.
$title= get_the_title();
现在变量已设置,您可以稍后使用它,除非它被覆盖.
Now the variable is set, you can use it later unless it is overwritten.
在你的 js 中:
keyword="<?php echo $title; ?>"
这篇关于如何在 Wordpress 中显示帖子标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!