1
對於我的FrontPage,我使用的是FrontPageSlideshow,它會生成顯示文章的html/css/javascript元素,而不是。目前,它從文件中提取靜態條目。我能夠使它成爲我工作過的Drupal網站的動態網站,但現在我被困在了Wordpress網站上。在隨機文件中使用wordpress循環
在該文件中,我嘗試在我的Wordpress主題中包含一個php文件。
<?php
$show = new WP_Query();
$show = query_posts(array(
'category_name' => 'News',
'posts_per_page' => 4,
'orderby' => 'date',
'order' => 'DESC',
));
if (have_posts()) :
while (have_posts()) : the_post() :
$recentStories['article'.$articleNumber] = array(
id => $post->ID,
title => wp_title(),
summary_name => $post->post_name,
dateMade=> the_date(),
image => get_post_meta($post->ID, 'fp_image', true),
summary => get_excerpt()
);
$articleNumber++;
endwhile;
endif;
?>
但問題是,它似乎無法返回我的任何WordPress的帖子。這個文件被包含在另一個文件中
$articleNumber = 1;
$recentStories = array();
include("wp-content/themes/Website/frontpage-post.php");
$slides = array();
// --- Start slide list ---
for ($counter = 1; $counter <= 4; $counter++) {
// slide elements
array_push($slides, array(
'slidelink' => 'http://IPHERE/website/?p=' . $recentStories['article'.$counter]['id'],
'title' => $recentStories['article'.$counter]['title'],
'category' => 'News',
'tagline' => $recentStories['article'.$counter]['summary'],
'text' => $recentStories['article'.$counter]['summary_name'],
'slideimage' => $recentStories['article'.$counter]['image'],
)
);
};
但是,我的循環一直返回一個空數組。我想知道是否可以在index.php頁面之外使用Wordpress循環。
假設兩個文件都在活動主題文件夾,你試圖切換包括對..`包括(「frontpage- post.php「);` – t31os 2010-12-22 17:18:50