Warning: get_headers(): open_basedir restriction in effect. File(/etc/ssl/certs/ca-certificates.crt) is not within the allowed path(s): (/www/wwwroot/at8848.cn/:/tmp//) in /www/wwwroot/at8848.cn/wp-content/plugins/wpwatermark/WaterMarkConfig.php on line 121

Warning: failed loading cafile stream: `/etc/ssl/certs/ca-certificates.crt' in /www/wwwroot/at8848.cn/wp-content/plugins/wpwatermark/WaterMarkConfig.php on line 121

Warning: get_headers(): Failed to enable crypto in /www/wwwroot/at8848.cn/wp-content/plugins/wpwatermark/WaterMarkConfig.php on line 121

Warning: get_headers(https://www.at8848.cn/wp-content/themes/YunPlus/assets/images/footer-logo.png): failed to open stream: operation failed in /www/wwwroot/at8848.cn/wp-content/plugins/wpwatermark/WaterMarkConfig.php on line 121
AT互联|WordPress如何调用指定ID文章_
AT互联|WordPress如何调用指定ID文章_
AT互联|WordPress如何调用指定ID文章_手机扫码预览

AT互联|WordPress如何调用指定ID文章_

1.26K
免费 优惠信息:免费 暂无永久SVIP下载特权
  • 免费售前咨询
  • 登录下载更划算哦
  • 付费安装资源
  • 付费终身升级
  • QQ保障售后服务
  • 网站应急咨询顾问

最近又在折腾自己的wordpress博客,突然想把之前博客调用置顶文章的区块改成调用指定ID文章,于是便寻思着如何实现。

在网上搜了搜,发现利用WordPress函数get_post(),能够调用指定ID的文章链接、标题及内容。

下面是调用文章ID为1的文章:

<?php
$post_id = 1; // 文章ID
echo get_post( $post_id )->post_content; // 输出文章的内容
echo get_post( $post_id )->post_title; // 输出文章的标题
?>

下面是调用文章ID为1,2,3的文章:

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

 

文章来自AT互联https://www.at8848.cn转载请注明出处,谢谢!!!

打破行业潜规则-更多选择 更低价格 更快交付!
AT互联全栈开发服务商 » AT互联|WordPress如何调用指定ID文章_
授权状态错误!请在后台进行授权验证,联系:云点网 进行授权!
欢迎您光顾,建议使用 QQ 登录
下午时段我们正在优化细节,力求做一个人见人爱的“细节控”哦~