Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom dia,
Criei um template para exibir apenas a categoria "portfolio" dos posts adicionados e dentro desse template, incluí um filtro com as subcategorias.
Com o intuito de que, quando clicar em uma subcategoria, aparecer na mesma página, os itens pertencentes a subcategoria em questão.
Página criada: http://www.afirmaweb.com.br/portfolio-2/
Código do Filtro:
<div class="filter">
<?php
/*RECUPERA SUBCATEGORIAS PARA O FILTRO - ADICIONADO POR PAULO FAUSTINI*/
$filtro = array(
'type' => 'post',
'child_of' => 60,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'category',
'pad_counts' => false
);
$filters = get_categories($filtro);
?>
<ul id="works_filter">
<li data-id="term-all">
<a href="#" class="active"><?php _e('TUDO', __SLUG__); ?></a>
</li>
<?php foreach($filters as $filter): ?>
<li data-id="<?php echo str_replace(' ', '-', strtolower($filter->name)); ?>">
<a href="#"><?php echo $filter->name; ?></a>
</li>
<?php endforeach; ?>
</ul>
<span class="clear"></span>
</div>Código para exibição dos posts:
<!-- EXIBIÇÃO DOS POSTS -->
<?php if(have_posts()) : ?>
<div id="posts" class="triple grid">
<?php while(have_posts()): the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(array('postbox')); ?>>
<div class="posthead">
<?php
$postmeta = get_post_meta(get_the_ID(), 'post_meta_box', true);
if(is_array($postmeta) && $postmeta['video']['type'] != '0'):
if($postmeta['video']['type'] == 'vimeo'): ?>
<iframe src="http://player.vimeo.com/video/<?php echo $postmeta['video']['url'];?>?title=0&byline=0&portrait=0" width="100%" height="240" frameborder="0" webkitallowfullscreen="" allowfullscreen=""></iframe>
<?php elseif($postmeta['video']['type'] == 'youtube'): ?>
<iframe width="100%" height="240" src="http://www.youtube.com/embed/<?php echo $postmeta['video']['url'];?>" frameborder="0" allowfullscreen></iframe>
<?php
endif;
else:
if ( has_post_thumbnail() ) {
the_post_thumbnail('blog-thumb');
}
endif;
?>
</div>
<div class="postboxmain">
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h2>
<p>
<?php echo excerpt(170); ?>
</p>
</div>
<div class="postboxfooter">
</div>
</div>
<?php endwhile; ?>
<span class="clear"></span>
</div>
<?php else: ?>
<div class="postbox">
<div class="postboxmain">
<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', __SLUG__ ); ?></p>
</div>
<div class="postboxfooter"></div>
</div>
<?php endif; ?>
</section>
<!-- end inside -->
</article>
<!-- end main -->
<?php get_footer(); ?>Alguém saberia me informar, como fazer meu filtro funcionar da maneira pretendida?Carregando comentários...