投资组合部分不适用于wordpress

时间:2015-04-07 06:22:19

标签: wordpress

我已将模板转换为WordPress主题,但我的投资组合部分无效。我制作了自定义帖子类型,并将自定义分类名称初始名称添加为console。虽然它正在获取类别名称,但是当点击类别名称时,它不会显示与之相关的图像。

我的代码是:

<?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/

1 个答案:

答案 0 :(得分: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就像这个流程js文件一样

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);