【发布时间】:2014-10-28 01:43:55
【问题描述】:
到目前为止我发现了什么:
我有一个这样的查询:
$categories=get_category_by_slug('my_category_slug')
$posts_array = get_posts( array('category'=>$categories->cat_ID, 'numberposts' => -1 ));
foreach($posts_array as $post_array){
$queried_post = get_post($post_array->ID);
//I can get the source file link this way: wp_get_attachment_url( get_post_thumbnail_id($queried_post->ID))
}
但是源文件太大了。 the_post_thumbnail( medium ) 之类的函数对我不起作用,因为它不仅仅是 url。这是一个带有图像标签包装器等的 url。那么有没有办法获取到中(或小)大小文件的链接?
也可以在functions.php中设置主题支持和post-thumbnail行之后的post-thumbnail大小:
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 300, 300 );
我没有尝试过,但我不想设置所有缩略图的大小。
【问题讨论】:
标签: php wordpress thumbnails