2017-08-07 34 views
1

我正在建设一个狗采用网站,以帮助在保加利亚的当地避难所。显示模板文件上的自定义解剖

我制作了一个名为'Adoptable Dogs'的自定义帖子类型 附加了几个自定义解剖结构:'性别','年龄','大小'和'组织'。这可以让人们更容易根据自己的喜好搜索存档。

在这个帖子类型的单一模板文件我想简单地回声定制解剖学内的选定的术语。

这是我在谈论的页面之一:http://animalfriendsvratsa.roxtest.nl/adoptable_dogs/lyuba/

我发现一对夫妇需要邮政ID但get_the_ID资源()函数将无法正常工作。

任何帮助将不胜感激,在此先感谢!

<?php 
/** 
* This template is for displaying the single pages for Adoptable Dogs 
* 
* @package Animal Friends Vratsa Theme 
* @since Custom Theme 1.0 
*/ 
?> 
<?php get_header(); ?> 
<div class="container"> 
    <div class="row"> 
    <div class="col-md-8"> 
       <?php $photos = get_field('photos'); ?> 

       <?php $name = get_field('name_dog'); ?> 
       <?php $breed = get_field('breed'); ?> 
       <?php $born_in = get_field('born_in'); ?> 
       <?php $weight = get_field('weight'); ?> 
       <?php $neutered = get_field('neutered'); ?> 
       <?php $vaccinated = get_field('vaccinated'); ?> 
       <?php $microchipped = get_field('microchipped'); ?> 
       <?php $eu_passport = get_field('eu_passport'); ?> 
       <?php $full_description = get_field('full_description'); ?> 
       <?php $suitable_for_children = get_field('suitable_for_children'); ?> 
       <?php $suitable_for_elderly_people = get_field('suitable_for_elderly_people'); ?> 
       <?php $suitable_for_cats = get_field('suitable_for_cats'); ?> 
       <?php $suitable_for_other_dogs = get_field('suitable_for_other_dogs'); ?> 
       <?php $suitable_for_apartment = get_field('suitable_for_apartment'); ?> 

        <?php $sex ?> 
        <?php $age ?> 
        <?php $size ?> 
        <?php $organisation ?> 

       <div class="container"> 
        <div class="row"> 
         <div class="col-md-6"> 
         <?php 
         $images = get_field('photos'); 

         if($images): ?> 
          <div class="row"> 
           <?php foreach($images as $image): ?> 
            <div class="col-md-3"> 
             <a href="<?php echo $image['url']; ?>"> 
              <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /> 
             </a> 
             <p><?php echo $image['caption']; ?></p> 
            </div><!--col-md-2--> 
           <?php endforeach; ?> 
          </div><!--row--> 
         <?php endif; ?> 
         </div> 

         <div class="col-md-6"> 
         <div class="row"> 

          <div class="col-md-6"> 
          <p>Name: <?php echo $name; ?></p> 
          <p>Breed: <?php echo $breed; ?></p> 
          <p>Age: <?php echo $age; ?></p> 
          <p>Weight: <?php echo $weight; ?></p> 
          </div><!--col-md-6--> 

          <div class="col-md-6"> 
          <p>Sex: <?php echo $sex; ?></p> 
          <p>Size: <?php echo $size; ?></p> 
          <p>Born in: <?php echo $born_in; ?></p> 
          <p>Organisation: <?php echo $organisation ?></p> 

         </div><!--col-md-6--> 
         </div><!--row--> 
         <p><?php echo $full_description; ?></p> 

         <div class="row"> 
          <div class="col-md-6"> 
          <p>Neutered: <?php 
          if($neutered==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 

          <p>Vaccinated: <?php 
          if($vaccinated==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 

          <p>Microchipped: <?php 
          if($microchipped==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 

          <p>EU Passport: <?php 
          if($eu_passport==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 
         </div><!--col-md-6--> 
         <div class="col-md-6"> 
          <p>Suitable for children: <?php 
          if($suitable_for_children==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 
          <p>Suitable for elderly people: <?php 
          if($suitable_for_elderly_people==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 
          <p>Suitable for cats: <?php 
          if($suitable_for_cats==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 
          <p>Suitable for other dogs: <?php 
          if($suitable_for_other_dogs==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 
          <p>Suitable for apartment: <?php 
          if($suitable_for_apartment==1){ 
          echo "Yes"; 
          }else{ 
          echo "No"; 
          }?></p> 
          </div><!--col-md-6--> 
         </div><!--row--> 
         </div><!--col-md-6--> 
        </div><!--row--> 
       </div><!--container--> 
     <?php 
      if (is_singular('post')) { 
       the_post_navigation(array(
        'next_text' => '<button class="btn btn-default">Next</button>', 
        'prev_text' => '<button class="btn btn-default">Previous</button>' 
       )); 
      } 
     ?> 
    </div> 
    </div> 
</div> 
<?php get_footer(); ?> 

回答

0

我只是删除所有的代码,只集中在你的代码希望这可以帮助你,请分配上$分类分类...

<?php 
/** 
* This template is for displaying the single pages for Adoptable Dogs 
*/ 
get_header(); ?> 

<?php $term_main = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); 


     $args = array(
      'orderby'   => 'name', 
      'order'    => 'ASC', 
      'hide_empty'  => false, 
      'exclude'   => array(), 
      'exclude_tree'  => array(), 
      'include'   => array(), 
      'number'   => '', 
      'fields'   => 'all', 
      'slug'    => '', 
      'parent'   => $term_main->term_id, 
      'hierarchical'  => true, 
      'child_of'   => 0, 
      'childless'   => false, 
      'get'    => '', 
      'name__like'  => '', 
      'description__like' => '', 
      'pad_counts'  => false, 
      'offset'   => '', 
      'search'   => '', 
      'cache_domain'  => 'core' 
    ); 
     $taxonomy='yourtaxonomy'; 

     $terms = get_terms($taxonomy, $args); ?> 

     <?php foreach($terms as $term){ 
      ?> 
      <?php echo $term->name; ?> 
      <?php 
      } ?> 

<?php get_footer(); ?> 
相关问题