2017-08-07 64 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(); ?> 
相關問題