我正在研究wordpress主题并试图设计我的博客页面 . 每个博客的 Headers 都没有链接到相应的完整个人博客帖子 . 有人可以告诉我该怎么做?我对wordpress很新,不知道从哪里开始!
看起来你正在寻找 <?php the_permalink() ?> 这是一个意味着在Wordpress循环中使用的PHP块 .
<?php the_permalink() ?>
Wordpress Codex for the Permalink Function
用法在那里解释,但基本上,如果你在循环中(也就是说,你正在迭代你的帖子而Wordpress用PHP吐出它们)你可以做这样的事情
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
显然我'm a little rusty and I'我不确定 the_title() 在语法上是否正确,但这背后的想法是你想要使用PHP的这些小片段,以便更好地呈现你的帖子 .
the_title()
希望能让你开始走上正轨!
编辑:如果你're, however, NOT using the loop, there' s等效函数 get_permalink() found here
get_permalink()
它's worth noting that it doesn' t显示链接,所以你必须使用 echo 才能输出 the_permalink(); 的返回值,这是获取永久链接的方法,如果你不是looping through your posts and outputting them .
echo
the_permalink();
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
看看代码,完全按照HTML和PHP . 你也可以看到wordpress示例主题 . 你可能只是这样做:
<h1><?php the_title(); ?></h1>
如果您粘贴代码,我们可以确切地说出问题所在 .
2 回答
看起来你正在寻找
<?php the_permalink() ?>
这是一个意味着在Wordpress循环中使用的PHP块 .Wordpress Codex for the Permalink Function
用法在那里解释,但基本上,如果你在循环中(也就是说,你正在迭代你的帖子而Wordpress用PHP吐出它们)你可以做这样的事情
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
显然我'm a little rusty and I'我不确定
the_title()
在语法上是否正确,但这背后的想法是你想要使用PHP的这些小片段,以便更好地呈现你的帖子 .希望能让你开始走上正轨!
编辑:如果你're, however, NOT using the loop, there' s等效函数
get_permalink()
found here它's worth noting that it doesn' t显示链接,所以你必须使用
echo
才能输出the_permalink();
的返回值,这是获取永久链接的方法,如果你不是looping through your posts and outputting them .看看代码,完全按照HTML和PHP . 你也可以看到wordpress示例主题 . 你可能只是这样做:
如果您粘贴代码,我们可以确切地说出问题所在 .