Wordpress用特色图片显示和查询帖子
通过在Wordpress用特色图片显示和查询帖子,wordpress,wordpress-theming,Wordpress,Wordpress Theming,通过在functions.php add_theme_support('post-thumbnails'); 我创建了3篇带有特色图片的帖子,我想在主页上显示它们,如本链接阅读部分所示 我正在尝试做以下事情来获得我的帖子 $args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'order' => 'asc'
functions.php
add_theme_support('post-thumbnails');
我创建了3篇带有特色图片的帖子,我想在主页上显示它们,如本链接阅读部分所示
我正在尝试做以下事情来获得我的帖子
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'order' => 'asc'
);
$home_shows = new WP_Query($args);
// var_dump($home_shows);
echo "<pre>";
print_r($home_shows->posts);
echo "</pre>";
现在,我不知道如何调用我在顶部查询的帖子的特色图像。因为在我调用特征图像之前已经获取了内容
使用此查询获取文章标题、内容和未来缩略图
图片:
使用此查询获取文章标题、内容和未来缩略图
图片:
对于特定页面,获取页面标题、内容和未来图像:
对于特定页面,获取页面标题、内容和未来图像:
$page = get_page(1);
print_r($page);
if ( has_post_thumbnail() ) {
the_post_thumbnail(array(486,226));
}
the_content();
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'order' => 'asc'
);
$query = new WP_Query($args);
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
?>
<h1><a href="<?php echo the_permalink(); ?>"><?php echo get_the_title();?></a></h1>
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail(array(486,226));
}
echo the_content();
}
}
?>
<?php query_posts("page_id=36");
while ( have_posts() ) : the_post()
?>
<h1><a href="<?php echo the_permalink(); ?>"><?php echo get_the_title();?></a></h1>
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail(array(486,226));
} ?>
<?php the_content(); ?>
<?php
endwhile;
wp_reset_query();
?>