Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Wordpress中显示文章标题?_Wordpress - Fatal编程技术网

如何在Wordpress中显示文章标题?

如何在Wordpress中显示文章标题?,wordpress,Wordpress,我想在下面的javascript代码中生成wordpress帖子标题:我将此代码放在wordpress帖子的内容下面 <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&toolI

我想在下面的javascript代码中生成wordpress帖子标题:我将此代码放在wordpress帖子的内容下面

<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>' );

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=709AE&color2=[COLORTWO]&format=ImageLink&contentType=TEXT_和_IMAGE&enableSearch=y&UsePopularSearch=n&freeShipping=n&topRatedSeller=y&itemsWithPayPal=n&descriptionSearch=n&showKwCatLink=n&excludeCatId=n&excludeKeyword=&catId=177913%2C179767%2C1059&disWithin=200&ctx=n&autoscroll=n&Flashnabled=+IsFlashnabled+&pageTitle='+&pageTitle='+&pageTitle='(Math.floor(Math.random()*10000000))+“>\x3C/script>”;

脚本的关键字=部分是我需要生成wordpress帖子标题的地方。我尝试了
关键字=
,但它没有生成wordpress帖子标题…不确定我是否在正确的轨道上

任何帮助都将不胜感激。请记住我是个新手。如果我忘了提什么,请询问。我会很快做出回应


非常感谢!

在循环中请参见
if(have_posts())
while
,在
while
语句中使用此选项

$title= get_the_title();
现在设置了变量,以后可以使用它,除非它被覆盖

在您的js中:

keyword="<?php echo $title; ?>"
keyword=“”

有一种简单的方法可以用于博客帖子和普通页面。如下所示:



显示PHP代码!呈现的HTML根本没有帮助。你最好在WordPress StackExchange网站上发布你的问题:显示什么PHP代码?我在那边问过它……WordPress是PHP。所以我想看看你为创建OP中的HTML而编写的代码。你只能在PHP文件中使用
,所以我假设在那里是更多的代码。你在哪里做这件事呢?如果单贴标题()失败您不在单个帖子循环中,或者没有标题集。@Julian-php代码是我的薄弱尝试。此javascript代码位于我的wordpress帖子的内容下。这很好,但我遇到了一个小问题。我需要标题中的空格为+(加号)没有空格。你能帮我一下吗?结果应该是keyword=“Capture+the+Moment”而不是keyword=“Capture the Moment”。也许可以用一个过滤器来删除空格并替换为+符号?非常感谢。这很有帮助!
$title=str_replace(“”,+”,get_the_title())
非常感谢你的帮助。你把每件事都解释得很清楚,像我这样的新手都能理解。真的谢谢你!