【发布时间】:2018-01-14 20:52:15
【问题描述】:
我正在建立一个狗收养网站来帮助保加利亚当地的收容所。
我制作了一个名为“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(); ?>
【问题讨论】:
标签: php wordpress display term