2012-10-09 40 views
0

我怎样才能得到WordPress的文章的标题在这个PHP代码如何获得WordPress的文章的标题在PHP

<?php include("imdb.php"); $imdb = new Imdb(); $movieArray = 
$imdb->getMovieInfo("**.get_the_title().**"); echo '<table 
cellpadding="3" cellspacing="2" border="1" width="80%" 
align="center">'; foreach ($movieArray as $key=>$value){ 
    $value = is_array($value)?implode("<br />", $value):$value; 
    echo '<tr>'; 
    echo '<th align="left" valign="top">' . strtoupper($key) . '</th><td>' . $value . '</td>'; 
    echo '</tr>'; } echo '</table>'; ?> 

我试图把".get_the_title()."但不会导致当前文章的标题。

+0

**在开始和结束时有什么? – Prasanth

+1

我没有这个**在我的PHP代码...只是在这里有问题显示 –

+0

你在“循环”? – Prasanth

回答

1

我假设你的代码是在WordPress的循环,所以你只需要使用:

$imdb->getMovieInfo(get_the_title()); 

使用$imdb->getMovieInfo("**.get_the_title().**");因为PHP不工作不处理函数内部字符串:http://www.php.net/manual/language.types.string.php

+0

非常感谢!现在它工作 –

0

get_the_title()功能要求您通过$id,如果您不在循环。如果你在循环中,并且想要使用当前帖子的ID来获得标题,那么你可以调用该函数不传递任何东西。

请参阅get_the_title,the_loop

相关问题