Wordpress获取标题变量不起作用

时间:2014-05-26 12:54:51

标签: javascript wordpress title

我试图使用

<?php echo get_the_title($ID); ?> 

阅读wordpress帖子的标题但由于某种原因不能在我的wordpress博客上工作:( 这是帖子:

http://tinyurl.com/mxq25wb

以下是我用作图片按钮的源代码

<a href="http://www.downloadthesefiles.com/Download/?ci=8138&amp;q=&lt;?php echo get_the_title($ID); ?&gt;" rel="nofollow"><img class="alignnone wp-image-1133 size-full" src="http://hack-games.info/wp-content/uploads/2014/05/download-no-survey.jpg" alt="" width="235" height="59" /></a>

这是下载链接:

<a href="http://www.downloadthesefiles.com/Download/?ci=8138&amp;q=&lt;?php echo get_the_title($ID); ?&gt;" rel="nofollow">Download Mirror2</a>

如果我使用它甚至没有显示下载链接:

<a href="http://www.downloadthesefiles.com/Download/?ci=8138&amp;q=<?php echo get_the_title($ID); ?>" rel="nofollow">Download Now Mirror2</a>

我是否必须添加任何其他内容才能使其正常工作?

还注意到javascript不能在我的wordpress上工作,我不知道如何解决它,我甚至不能添加一个简单的警报到我的wordpress网站:( 也许是标题中的代码?

请帮帮我,谢谢!

1 个答案:

答案 0 :(得分:0)

因为你的php标签是&amp; lt;?php&#34;当然,它不起作用。

此外,您应该将您的字符串转换为web safe uri。

试试这个。

<a href="http://www.downloadthesefiles.com/Download/?ci=8138&q=
<?php echo urlencode(get_the_title($post->ID)); ?>" rel="nofollow">Download Mirror2</a>

这就是为什么您的导游链接无效。

改变这个:

<em>If you have any download problems read <a href=" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.downloadthesefiles.com']);"http://hack-games.info/download/">this guide</a> !</em> 

到此:

<em>If you have any download problems read <a href="http://hack-games.info/download/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.downloadthesefiles.com']);">this guide</a> !</em>

修改 您的PHP代码不起作用,因为您无法在文章中使用php