WordPress若何解决文章ID不延续的问题_wordpress教程
最近又在折腾自己的wordpress博客突然想把之前博客挪用置顶文章的区块改成挪用指定ID文章于是便寻思着若何实现。
在网上搜了搜发现行使WordPress函数get_post()能够挪用指定ID的文章链接、问题及内容。
下面是挪用文章ID为1的文章:
wordpress主题wordpress错误_WordPress获取文章摘要函数the_excerpt详解
<?php
$post_id = 1; // 文章ID
echo get_post( $post_id )->post_content; // 输出文章的内容
echo get_post( $post_id )->post_title; // 输出文章的问题
?>
下面是挪用文章ID为123的文章:
<?php
$postsl = get_posts(\"numberposts=4&post_type=any&include=123\");
if($postsl) : foreach( $postsl as $post ) : setup_postdata( $post );
?>
<li><a href=\"<?php%20the_permalink();%20?>\" rel=\"external nofollow\" ><?php the_title();?></a></li>
<?php endforeach; endif; ?>