2013-07-20 33 views
0

我已經開發了一個基於2個自定義帖子類型的供應商目錄,在我的主頁共享相同的分類標準,這麼好,我顯示了註冊廣告客戶訪問條款列表,就像風格列表wordpress 2自定義帖子類型和1 taxonomie

Screenshot 1enter image description here

,一切都很好....但....

這裏開始的問題。

我與已註冊廣告客戶的列表的頁面中的任何自定義文章類型,但我想的是,根據定義文章類型每件物品都有其風格...

Screenshot 2enter image description here

名爲「上級目錄」和不同的風格命名的自定義職位類型的自定義類型後的樣式「Basico酒店」共享分類法被稱爲「categoria」

在屏幕截圖2,樣本...奧斯卡納瓦羅有已在自定義帖子類型「basico」中註冊,「Carlos GalarzaFotografía」已在自定義帖子類型「directorio」中註冊。

是posible添加類到每個自定義帖子類型的樣式不同的CSS?

回答

0

可以在循環檢查後類型,並添加類到後

請檢查內容template_part

試圖修改模板部分像下面

<?php if (have_posts()) while (have_posts()) : the_post(); ?> 
<?php 
global $post; 
       <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 


      <a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('Permalink to %s', 'twentyten'), the_title_attribute('echo=0')); ?>" rel="bookmark"> 
       <?php the_post_thumbnail('large');?> 
      </a> 
     </span> 


<?php endwhile; // end of the loop. ?> 

添加這功能.php

add_filter('post_class','your_post_class' , 20, 3); 

    public function your_post_class($classes, $class, $post_id) { 
     if ('basico' == get_post_type()){ 
       $classes[] = 'basico_class'; 
      }elseif ('directorio' == get_post_type()){ 
       $classes[] = 'directorio_class'; 
      } 
     return $classes; 
} 
+0

Tnxs BL praveen,我是一個WordPress初學者... –

+0

as ... <?php if('basico'== get_post_type()){ get_template_part('style','basico'); ('directorio'== get_post_type()){ get_template_part('style','directorio'); }?> 此代碼查找... style-basico.php和style-directorio.php ??? TNXS! –

+0

你不能這樣做..在get_template_part()內部,你需要在post_type.not之前檢查....循環在get_template_part()內部開始; –

相關問題