2015-04-07 71 views
1

我已將模板轉換爲WordPress主題,但我的投資組合部分不起作用。我已經做了一個自定義的帖子類型,並添加自定義分類init名稱爲console。儘管它獲取類別名稱,但點擊類別名稱時卻不顯示與其相關的圖像。投資組合部分不在wordpress中工作

我的代碼是:

<?php 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
$loop = new WP_Query(array(
'post_type' => 'portfolio', 
'posts_per_page' => 9, 
'orderby'=> 'menu_order', 
)); ?> 
    <section id="work" class="text-center wow fadeInDown" data-wow-delay="2000" style="background-color:<?php echo $theme_options['section2_scheme']; ?>;"> 
    <div class="container"> 
    <div class="center"> 
     <h2><?php echo $theme_options['section3-heading']; ?></h2> 
     <hr class="skills_hr"/> 
     <p><?php echo $theme_options['section3-subheading']; ?></p> 
    </div> 
    <?php 

    $taxonomy = 'console'; 
    $post_type='portfolio'; 
    $terms = get_terms($taxonomy); // Get all terms of a taxonomy 

if ($terms && !is_wp_error($terms)) : 
$counter=0; 
    ?> 

    <ul class="portfolio-filter text-center"> 
     <?php foreach ($terms as $term) { 
     $counter=$counter+1; 
     ?> 
     <li><a class="btn btn-default <?php if($counter==1){echo "active";}?>" 
     href="#<?php echo $term->slug ?>" data-filter=".<?php echo $term->slug; ?>" > 
     <?php echo $term->name; ?></a></li> 

     <?php } ?> 
</ul> 

<?php endif;?> 
    <!--/#portfolio-filter--> 
    <div class="row"> 
     <div class="portfolio-items "> 
     <?php while ($loop->have_posts()) : $loop->the_post(); ?> 
      <?php 

      $category = get_the_category(get_the_ID()); 

      ?> 
      <div class="portfolio-item <?php echo $term->slug; ?> col-xs-12 col-sm-4 col-md-3"> 
       <div class="recent-work-wrap"> 
        <div class="img-responsive"> 
        <?php the_post_thumbnail('post-thumbnail');?></div> 
       <div class="overlay"> 
        <div class="recent-work-inner"> 
         <h3><a href="#"><?php the_title(); ?></a></h3> 
         <p><?php the_excerpt(); ?></p> 
         <a href="#" class="preview" rel="prettyPhoto"> 
        <i class="fa fa-eye"></i> View</a> 
        </div> 
       </div> 
       </div> 
      </div> 
      <?php endwhile; ?> 
      <!--/.portfolio-item--> 

     </div> 
    </div> 
    </div> 

,我想讓它像這樣

http://responsive.co.il/bedford/featured-works/

回答

0

工作,你改改作爲這樣

的index.php

<!--------------------------------start work------------------------------------------> 
<?php 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
$loop = new WP_Query(array(
    'post_type' => 'portfolio', 
    'posts_per_page' => 9, 
    'orderby' => 'menu_order', 
     )); 
?> 
<section id="work" class="text-center wow fadeInDown" data-wow-delay="2000" style="background-color:<?php echo $theme_options['section2_scheme']; ?>;"> 
    <div class="container"> 
     <div class="center"> 
      <h2><?php echo $theme_options['section3-heading']; ?></h2> 
      <hr class="skills_hr"/> 
      <p><?php echo $theme_options['section3-subheading']; ?></p> 
     </div> 
     <?php 
     $taxonomy = 'console'; 
     $post_type = 'portfolio'; 
     $terms = get_terms($taxonomy); // Get all terms of a taxonomy 

     if ($terms && !is_wp_error($terms)) : 
      ?> 

      <ul class="portfolio-filter text-center"> 
       <li class="te"><a class="btn btn-default" 
            href="javascript:void(0)" data-filter="*" >All</a></li> 
        <?php foreach ($terms as $term) { ?> 
        <li class="te"><a class="btn btn-default" 
             href="javascript:void(0)" data-filter=".<?php echo $term->slug; ?>" > 
          <?php echo $term->name; ?></a></li> 

       <?php } ?> 
      </ul> 

     <?php endif; ?> 
     <!--/#portfolio-filter--> 
     <div class="row"> 
      <div class="portfolio-items "> 
       <?php while ($loop->have_posts()) : $loop->the_post(); ?> 
        <?php 
        $category = wp_get_post_terms(get_the_ID(), 'console'); 
        $result = array(); 
        foreach ($category as $key => $value) { 
         $result[] = $value->slug; 
        } 

        ?> 
        <div class="portfolio-item joomla <?php echo $result[0]; ?> col-xs-12 col-sm-4 col-md-3"> 
         <div class="recent-work-wrap"> 
          <div class="img-responsive"> 
           <?php the_post_thumbnail('post-thumbnail'); ?></div> 
          <div class="overlay"> 
           <div class="recent-work-inner"> 
            <h3><a href="#"><?php the_title(); ?></a></h3> 
            <p><?php the_excerpt(); ?></p> 
            <a href="#" class="preview" rel="prettyPhoto"> 
             <i class="fa fa-eye"></i> View</a> 
           </div> 
          </div> 
         </div> 
        </div> 
       <?php endwhile; ?> 
       <!--/.portfolio-item--> 

      </div> 
     </div> 
    </div> 
</section> 

和functions.php的像順序

wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery.js', true); 
wp_enqueue_script('quicksand', get_template_directory_uri() . '/js/jquery.isotope.min.js', true); 
wp_enqueue_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', true); 
wp_enqueue_script('mainjs', get_template_directory_uri() . '/js/main.js', true); 
wp_enqueue_script('prettyPhotojs', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', true); 
wp_enqueue_script('textrotator', get_template_directory_uri() . '/js/jquery.simple-text-rotator.js', true); 
wp_enqueue_script('smoothscroll', get_template_directory_uri() . '/js/smoothscroll.js', true); 
wp_enqueue_script('wow', get_template_directory_uri() . '/js/wow.min.js', true); 
wp_enqueue_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', true); 
wp_enqueue_script('templatemo', get_template_directory_uri() . '/js/templatemo-script.js', true); 
wp_enqueue_script('top', get_template_directory_uri() . '/js/top.js', true); 
wp_enqueue_script('circlechart', get_template_directory_uri() . '/js/jquery.circlechart.js', true); 
+0

它仍然沒有工作 –

+0

我會派另一個文件中,頁面模板,它在工作時,此流程的js文件我pc ....檢查你的郵件 –

+0

當我點擊所有的工作,它顯示所有圖像,但當我點擊其他categries它隱藏所有圖像,當我點擊創意(categry)它隱藏所有圖像 –