0

是否可以使用以下方式在functions.php中定义WordPress永久链接:

<?php $permalink = the_permalink;?>

其中“the_permalink”使用内置的 WordPress 函数来获取博客的永久链接,然后$permalink在 functions.php 中进一步使用,例如,带有图像 URL:<img src="'.$permalink.'/images/image1.png'"/>

我只需要将 Peramlink 拉入 functions.php 以便在文件中进一步使用,就像上面的示例一样。要么 要么the_permalinkbloginfo('template_directory')很好用。

4

2 回答 2

0

您可以在函数中传递 ID ...例如 yourFunction($id) ,然后在实际函数中使用 get_permalink($id) 。

通常 the_permalink 用于您想要显示和格式化永久链接的情况,而 get_permalink 允许您将其传递给变量。

http://codex.wordpress.org/Template_Tags/get_permalink

于 2012-05-08T17:03:39.520 回答
0

我自己想通了。我最终在我的 functions.php 文件中使用了以下链接结构

<img src="'.get_bloginfo('stylesheet_directory').'/images/map-point-medical.png"/>
于 2012-05-21T18:19:59.873 回答