Php 在随机文件中使用wordpress循环

Php 在随机文件中使用wordpress循环,php,wordpress,Php,Wordpress,对于我的frontpage,我使用FrontPageSlideshow,它生成一个html/css/javascript元素来显示文章和其他内容。目前,它从文件中提取静态条目。我曾经为我工作过的Drupal站点创建了动态的页面,但现在我被困在Wordpress上了 在这个文件中,我试图包含一个位于Wordpress主题中的php文件 <?php $show = new WP_Query(); $show = query_posts(array( 'category_n

对于我的frontpage,我使用FrontPageSlideshow,它生成一个html/css/javascript元素来显示文章和其他内容。目前,它从文件中提取静态条目。我曾经为我工作过的Drupal站点创建了动态的页面,但现在我被困在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'],
  ) 
 );
};
$articleNumber=1;
$recentStories=array();
包括(“wp内容/主题/网站/frontpage post.php”);
$slides=array();
//---开始幻灯片列表---
对于($counter=1;$counter'http://IPHERE/website/?p=“.$recentStories['article.$counter]['id'],
'title'=>$recentStories['article'.$counter]['title'],
“类别”=>“新闻”,
'tagline'=>$recentStories['article'.$counter]['summary'],
'text'=>$recentStories['article'.$counter]['summary\u name'],
'slideimage'=>$recentStories['article'.$counter]['image'],
) 
);
};

但是,我的循环不断返回一个空数组。我想知道是否可以在index.php页面之外使用Wordpress循环。

对于在Wordpress系统之外访问的所有Wordpress,您必须包括
wp load.php

include("wp-load.php");
include("wp-content/themes/Website/frontpage-post.php");

假设两个文件都在活动主题的文件夹中,是否尝试将“包含”切换到<代码>包含(“frontpage post.php”)在此附议T31O-该路径绝对不起作用。如果你在它前面加了一个正斜杠,它看起来会相对于站点的根,但是如果这是你正在使用的确切路径,它将不起作用。您是否尝试过启用wp_debug来检查PHP错误?另外,在
$recentStories
变量上尝试使用
print\r()