以下是基础代码,根据自己需要进行修改!
<?php
$rand_posts = get_posts('numberposts=8&orderby=rand'); //循环随机显示文章数
foreach( $rand_posts as $post ) :
?>
<dl>
<?php
$litpic = get_post_meta($post->ID, 'litpic', true);
if (empty ( $litpic )) { //没有图片的文章
echo '';
}
else { //显示有图片的文章
echo '<dt><a href="'.get_permalink().'" title="'.trim(strip_tags( $post->post_title )).'"><img src="'. $litpic .'"/></a></dt>';
} ?>
<dd class="title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></dd>
</dl>
<?php endforeach; ?>
wordpress如何获取get_post_meta自定义属性
上面是“wordpress如何调用有图片的文章”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4486.html
workflows工作流
图片转视频ComfyUI工作流
树上站着一只鸟ComfyUI工作流
一轮月亮悬挂在树上的天空中ComfyUI工作流
文生图工作流:树枝上站着一只鸟
一只白色的孔雀ComfyUI工作流
一幅生动而古怪的时尚鸭子插图ComfyUI工作流
水晶玉雕巨龙ComfyUI工作流
一尊白玉猴王ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

帝国CMS7.0批量上传图片集【插件】+版本2增加获取
推荐一个免费开源以Bootstrap为主题快速构建web项目——FastBootstrap
















