如何从帖子ID获取永久链接和标题?
3 个回答
- 投票数
-
- 2012-02-20
<?php if(count($related)) { echo "<div>Read More<ul>"; foreach($related as $id) { echo '<li><a href="'.get_permalink( $id ).'">'.get_the_title( $id ).'</a></li>'; } echo "</ul></div>"; } ?>
<?php if(count($related)) { echo "<div>Read More<ul>"; foreach($related as $id) { echo '<li><a href="'.get_permalink( $id ).'">'.get_the_title( $id ).'</a></li>'; } echo "</ul></div>"; } ?>
-
您的答案...天才!:DYour answer...it's genius! :D
- 0
- 2012-02-20
- mor7ifer
-
-
- 2018-10-30
如果您没有访问权限,则可以尝试wp api
https://content.wordpress.com.au/wp-json/wp/v2/posts/POST_ID
If you dont have access you could try the wp api
https://content.wordpress.com.au/wp-json/wp/v2/posts/POST_ID
我存储了一个帖子ID数组,我想将这些帖子列为链接,这意味着我需要获取帖子ID-$id的标题和永久链接.下列if条件将回显该列表,这意味着我必须以某种方式将$id替换为永久链接和标题.目前,该代码仅列出了职位ID号.