我开始为Wordpress编写自定义主题。我创建了一个名为'Home'的新页面,并将首页设置为静态页面,选择'Home'。我希望此页面显示所有包含“新闻”类别和一些图片的帖子。获取静态主页的ID,而不是发布
我加入前page.php文件有以下几点:
<?php get_header(); ?>
<div class='detail'>
<?php if (have_posts()) {
query_posts('category_name=news');
while (have_posts()) : the_post(); ?>
<h4><?php the_date('d/m/Y'); ?> - <?php the_title(); ?></h4>
<div class='post'><?php the_content(); ?></div>
<?php endwhile; }?>
</div>
<?php get_footer(); ?>
我上传了一些图片,并将它们连接到“主页”。我现在想要获取附加图片的网址。我已经试过类似:
$images =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . get_the_ID());
但这只是返回最近的帖子的ID被显示,即使我把上面的代码外循环。如果我删除静态首页并导航到主页,那么我会得到正确的结果,当我将其用作静态页面时,如何获取主页图像?
原谅我,如果这是简单的,首次进军PHP和WordPress开发