我正在努力搜索。php模板。我想根据他们的帖子类型显示不同的结果。我有页面、帖子和机器(自定义帖子类型)
下面是当前结果页面的一个示例:http://dev.digitalgroupmedia.com/fortron/?s=fortron&search-submit=Submit+Query第一个结果是一个帖子,其他的都是机器
页面和帖子可以用一个简单的超链接标题来显示,但我希望机器具有当前的格式。
我的php并不令人惊奇,通常是通过随机尝试和错误拼凑起来的。我知道需要某种类型的if/else语句模板来检查帖子类型,然后在此基础上显示它们,但我很挣扎。任何帮助都将不胜感激。以下是我目前的代码:
<?php get_header(); ?>
“”的搜索结果
<?php $i = 1;?>
<?php if (have_posts()) : ?>
<div class="products row-fluid clearfix">
<?php while (have_posts()) : the_post(); ?>
<div class="span3 machine">
<a href="<?php the_permalink(); ?>">
<?php
$machineImage = types_render_field( "machine-image", array( "alt" => "Fortron Machine Tools", "title" => "Fortron Machine Tools", "width" => "184", "height" => "162", "align" => "center", "resize" => "pad", "padding_color" => "transparent", \'index\' => 0 ) );
if ($machineImage){
echo $machineImage;
};
?>
</a>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
</div>
<?php if($i % 4 == 0) {echo \'</div><!-- end machines row fluid --><div class="row-fluid clearfix">\';} ?>
<?php $i++; endwhile; ?>
</div><!-- end products row fluid -->
<?php else : ?>
<strong>Sorry, nothing found.</strong>
<?php endif; ?>
</div><!-- span8 end -->
<?php get_sidebar(); ?>
</div>
</div><!-- container end -->