Php 在模板文件上显示自定义解剖结构

Php 在模板文件上显示自定义解剖结构,php,wordpress,display,term,Php,Wordpress,Display,Term,我正在建立一个狗收养网站,帮助保加利亚当地的一个收容所 我做了一个自定义的帖子类型,叫做“可收养的狗” 与此相关的是一些自定义解剖:“性别”、“年龄”、“大小”和“组织”。这使得人们更容易根据自己的喜好搜索归档文件 在这篇文章类型的单个模板文件中,我只想在自定义解剖结构中回显所选的术语 这是我说的其中一页: 我发现一些资源需要Post ID,但是get_the_ID()函数不起作用 任何帮助都将不胜感激,提前谢谢 <?php /** * This template is for disp

我正在建立一个狗收养网站,帮助保加利亚当地的一个收容所

我做了一个自定义的帖子类型,叫做“可收养的狗” 与此相关的是一些自定义解剖:“性别”、“年龄”、“大小”和“组织”。这使得人们更容易根据自己的喜好搜索归档文件

在这篇文章类型的单个模板文件中,我只想在自定义解剖结构中回显所选的术语

这是我说的其中一页:

我发现一些资源需要Post 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(); ?>

姓名:

品种:

年龄:

重量:

性别:

尺寸:

出生于:

组织:

绝育:

接种疫苗:

微芯片:

欧盟护照:

适合儿童:

适合长者使用:

适合猫:

适用于其他狗只:

适用于公寓:


我刚刚删除了所有的代码,只关注你的代码,希望这可以帮助你,请在$taxonomy上分配taxonomy

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

我刚刚删除了所有代码,只关注您的代码,希望这对您有所帮助,请在$taxonomy上分配分类法

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