我只想创建一个指向我知道标题(或ID)的页面的链接,但我想确保它可以在任何Wordpress安装上运行。最好的方法是什么?
链接到模板PHP代码中的特定页面
1 个回复
最合适的回答,由SO网友:chrisguitarguy 整理而成
您可能想使用get\\u permalink并获取\\u标题。示例:
<a href="<?php echo get_permalink( YOUR POST ID ); ?>"><?php echo get_the_title( YOUR POST ID ); ?></a>
将您的帖子ID替换为您要链接到的帖子ID。然而,Post ID将随着安装的不同而变化,因此这可能无法按预期工作。http://codex.wordpress.org/Function_Reference/get_the_titlehttp://codex.wordpress.org/Function_Reference/get_permalink
结束