小冬SEO

wordpress通过ID调用指定文档或页面名称和链接

2019-05-11 16:28:35 2355 WordPress笔记

wordpress通过ID调用指定文档或页面名称和链接实现方法如下:

<?php 
$postsl = get_posts("numberposts=1&post_type=any&include=1"); 
if($postsl) : foreach( $postsl as $post ) : setup_postdata( $post ); 
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title();?></a></li>
<?php endforeach; endif; ?>

这样在你需要diaoy调用指定页面的地方加上上面的代码就行了,记住了调用标题和链接的是<?php the_permalink(); ?>和<?php the_title();?>,必须在下面这个标签中调用

<?php 
$postsl = get_posts("numberposts=1&post_type=any&include=1"); 
if($postsl) : foreach( $postsl as $post ) : setup_postdata( $post ); 
?>

<?php endforeach; endif; ?>
这样你就可以在指定的地方随意调用了!

版权保护: 本文由小冬SEO编辑发布,转载请保留链接: http://www.myseoyh.cn/shuo/116.html