【发布时间】:2017-09-29 16:05:56
【问题描述】:
下面的代码可以很好的获取帖子的URL和标题:
global $post;
$args = array( 'posts_per_page' => 5, 'offset'=> 1, 'category' => 4 );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post );
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <br />
<?php
endforeach;
wp_reset_postdata();
但是我需要的是获取特色图片的文本/网址,包括路径,但不将其打印到屏幕上。这样做的目的是让我可以使用 ImageMagick 转换创建自定义大小的图像,并将其显示到屏幕而不是原始图像。
我会做类似的事情
convert "$image" -resized (my custom size) -strip 400x/$image
转换代码有点复杂,因为我打算创建大的方形拇指,但这就是目标。然后,我会将图片发布到页面上的方形拇指墙风格画廊中,并附上指向各个帖子的链接。
有没有像 the_featured_image() 这样的东西可以让我得到图像,然后我可以将其设置为变量并运行转换代码?
【问题讨论】:
-
您是指帖子缩略图吗? the_post_thumbnail()
标签: php mysql wordpress imagemagick imagemagick-convert