我正在建立一个狗收养网站,以帮助保加利亚的当地避难所。
我做了一个名为'Adoptable Dogs'的自定义帖子类型 附有几个定制解剖学:“性”,“年龄”,“大小”和“组织”。这样可以让人们更容易根据自己的偏好搜索档案。
在此帖子类型的单个模板文件中我想简单地在自定义解剖结构中回显选定的术语。
这是我正在谈论的其中一个页面:http://animalfriendsvratsa.roxtest.nl/adoptable_dogs/lyuba/
我发现了一些需要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(); ?>
答案 0 :(得分:0)
我刚刚删除了所有代码,只关注您的代码,希望这对您有所帮助,请为$ 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(); ?>