gpt4 book ai didi

image - 带有图片的 Wordpress get_posts

转载 作者:行者123 更新时间:2023-12-04 03:06:31 24 4
gpt4 key购买 nike

所以,我想显示与图像一致的标题和摘录?我怎样才能做到这一点?

<div id="treia_box" style="height:350px; width:350px;"> 
<?php
add_filter('excerpt_length', 'new_excerpt_length');
global $post;
$args = array( 'numberposts' => 3, 'category' => 29 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<h2><a href="<?php the_permalink(); ?>"<?php the_title('<h7>', '<h7>'); ?></a></h2>
<?php $size = array(75,75);
echo get_the_post_thumbnail($post_id, $size)?>
<h6><?php the_excerpt(); ?></h6>
<?php endforeach; ?>
</div>

最佳答案

get_the_post_thumbnail($post_id, $size) 是正确的,但是:

1 - 您需要指定 $size ,例如: "large", "thumbnail""my_custom_size"

get_the_post_thumbnail($id, 'thumbnail');     // Thumbnail
get_the_post_thumbnail($id, 'medium'); // Medium resolution
get_the_post_thumbnail($id, 'large'); // Large resolution

get_the_post_thumbnail($id, array(100,100) ); // Other resolutions

2 - 仅当用户(您)定义帖子缩略图(特色 - 创建帖子时的图片)时才会起作用

关于image - 带有图片的 Wordpress get_posts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11048972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com