我開始爲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開發