我想要的是:如果一篇文章有标题,我想显示它
在wordpress.org编码中,您可以看到以下示例:
<?php the_title( $before, $after, $echo ); ?>
这个例子:
<?php the_title('<h3>', '</h3>'); ?>
我想做的是在href 中添加一个带有_permink的超链接
<?php the_title('<h3><a href=" the_permalink(); ">', '</a></h3>'); ?>
然而,这并不奏效。
换句话说:我该如何写the_permink()在显示的代码中?
我也尝试过:
<?php the_title('<h3><a href="' . the_permalink() . '">', '</a></h3>'); ?>
这导致:
mysite.com/?p=1
我的标题
<?php $permalink = get_permalink(); the_title('<h3><a href="' . $permalink . '">', '</a></h3>'); ?>
循环内部the_title()
将回显标题。你可以用这种方式写
<h3><a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>