您好,我正在尝试针对特定帖子进行分类以显示在特定页面上。WordPress针对特定页面上的特定帖子类别
我建立一个住房建筑商的网站,所以我必须交的类别,如
1)房屋出售 2)显示舍 3)特点的家园 4)可用批次
,我有网页核心反应到类别。 1)显示舍2)可用公寓3)可用批次
我试图做到的是,我要显示这样
组合在页(适用HOMES) - 所有帖子说的是分类/蛞蝓 “出售公寓”
在页面(SHOW HOMES) - 所有帖子说的是分类/蛞蝓 “展家”
我不知道如何做到这一点....
这是我得到了多少:
<?php if(have_posts()):?>
<?php while(have_posts()) : the_post();
$categoris = get_the_category();
print_r($categoris);
if($categories){
$class_names = array();
foreach($categories as $category){
$class_names[] = $category->slug;
}
$classes = join(' ', $class_names);
}
?>
<div class="row">
<div class="large-4 columns">
<div class="panel bodyHeight">
<?php if(has_post_thumbnail()) : ?>
<a href="<?php the_permalink();?>"><?php the_post_thumbnail(); ?></a>
<?php endif;?>
</div>
</div>
<div class="large-8 columns">
<div class="panel bodyHeight">
<p>Price:
<?php $custom_fields = get_post_custom();
$price = $custom_fields['price'];
foreach($price as $key => $value){
echo $value;
}
?>
</p>
<p>SqF:
<?php $custom_fields = get_post_custom();
$sqf = $custom_fields['sqf'];
foreach($sqf as $key => $value){
echo $value;
}
?>
</p>
<p>Number of Bedrooms:
<?php $custom_fields = get_post_custom();
$bed = $custom_fields['num_bedrooms'];
foreach($bed as $key => $value){
echo $value;
}
?>
</p>
<p>Number of Bathrooms:
<?php $custom_fields = get_post_custom();
$bath = $custom_fields['num_bathrooms'];
foreach($bath as $key => $value){
echo $value;
}
?>
</p>
<p>Home Description:
<?php $custom_fields = get_post_custom();
$desc = $custom_fields['description'];
foreach($desc as $key => $value){
echo $value;
}
?>
</p>
<p>Home Location:
<?php $custom_fields = get_post_custom();
$address = $custom_fields['address'];
foreach($address as $key => $value){
echo $value;
}
?>
</p>
</div>
</div>
</div>
<?php endwhile;?>
<?php else: ?>
<div class="row">
<div class="large-4 columns">
<div class="panel bodyHeight">
<h3>No posts were found.</h3>
</div>
</div>
</div> <?php endif;?>
</div>
谢谢,我已阅读第二个链接,但我处于主要时间线下,无法及时学习自定义类型。目前,我拥有我需要正确工作的一切,我需要的仅仅是学习如何按类别(过滤)当前帖子。 我现在所做的是为每个页面创建单独的页面,因此我有page-show-home.php并且我有页面'Show Home'使用该页面作为模板。我现在需要的是一个由slug/category – Ljubisa
的过滤器啊,所以我有点不清楚。每个页面都会知道这个slu,,你只需要从这个slu category的类别中获得帖子。那是对的吗? –
也要明白你的slu will不会是“单词”,他们会成为“单词”。“word word”将是名字 –