如何在定义的标记内打印?当它输出此代码时,the_title()将在h1标记的外部(之前)打印。
我的代码是:
<?php
if ( '' != get_the_post_thumbnail() ) {
print '<p>HEY</p>';
}
else {
print '<div class="page-header row full"><h1 class="page-title" itemprop="headline">', the_title() ,'</h1></div>';
}
?>我已经试过了:
<?php
if ( '' != get_the_post_thumbnail() ) {
print '<p>HEY</p>';
}
else {
print '<div class="page-header row full"><h1 class="page-title" itemprop="headline">'. the_title() .'</h1></div>';
}
?>我做错什么了?
谢谢
发布于 2014-08-25 09:44:41
你可以这样做:
<?php if ( '' != get_the_post_thumbnail() ): ?>
<p>HEY</p>
<?php else: ?>
<div class="page-header row full"><h1 class="page-title" itemprop="headline"><?php the_title(); ?></h1></div>
<?php endif; ?>或者使用get_the_title()(返回标题值)。
发布于 2014-08-25 09:42:32
试试print "....".get_the_title().".....";
方法"the_xxxx“打印值,方法"get_the_xxx”返回值。
发布于 2014-08-25 09:47:50
尝试回波而不是打印
echo - can output one or more strings
print - can only output one string, and returns always 1https://stackoverflow.com/questions/25483077
复制相似问题