2011-10-10 45 views
0

我正在自定義wordpress主題並使用this插件,我希望頁面只顯示特定類別,它還允許我選擇post-頁面編輯器中的類別。 SEE THIS IMAGE.但是,我最終不得不在每個模板頁面的get_post查詢中指定這樣的類別。這裏有一個例子:在Wordpress循環中,我想獲得與頁面關聯的類別名稱

<?php  
    $grid_classes = 'no-description grid_12 alpha omega'; 
    $frame_width = 1000; 
    $frame_height = 800; 
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    query_posts(array('category' => 'Motion Pictures', 'showposts' => 10));    
    if (have_posts()) while (have_posts()) : the_post(); 

     $video_url = of_get_the_video_url(); 
     $count++; 

?> 

有沒有一種方法可以讓我找回我同時使PAGE選定後類別(IES),從而使模板可以用不同的內容被重用?很多高級主題都是這樣做的,但我無法弄清楚。請幫忙。

回答

0

您可以通過

$categories=wp_get_post_categories($post->ID); 
0

<?php  
     $grid_classes = 'no-description grid_12 alpha omega'; 
     $frame_width = 1000; 
     $frame_height = 800; 
     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
     query_posts(array('category' => 'Motion Pictures', 'showposts' => 10));    
     if (have_posts()) while (have_posts()) : the_post(); the_category(); 

      $video_url = of_get_the_video_url(); 
      $count++; 

    ?> 
獲得分配給張貼或頁面類別ID(如數組)
相關問題