2010-12-22 4 views
1

내 frontpage에 기사를 표시하는 html/css/javascript 요소를 생성하는 FrontPageSlideshow를 사용하고 있습니다. 현재 정적 항목을 파일에서 가져옵니다. 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 루프를 사용할 수 있는지 궁금합니다. 모두를위한

+1

을 포함해야 "(frontpage- 포함 post.php "); ' – t31os

+0

여기에 t31os 설치 - 그 경로는 절대 작동하지 않습니다. 슬래시를 앞에 붙이면 사이트의 루트와 관련이있는 것으로 보이지만 사용중인 정확한 경로라면 작동하지 않습니다. wp_debug를 사용하여 PHP 오류를 검사 해 보셨습니까? 또한'$ recentStories' 변수에'print_r()'을 시도하십시오. – Gavin

답변

3

가이 워드 프레스 시스템 외부에 액세스 워드 프레스, 당신은`.. 당신은이에 포함 전환 시도가 두 파일이 활성 테마의 폴더에있는 가정 wp-load.php

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