WordPress.org

Ready to get started?Download WordPress

Forums

Filter by subcategory does not work (1 post)

  1. paulo.bemvisto
    Member
    Posted 5 months ago #

    Good morning,

    I created a template to display only the category "portfolio" added the posts within that template, include a filter with subcategories.

    In order that, when you click a subcategory, appear on the same page, the items belonging to the subcategory in question.

    Page created: http://www.afirmaweb.com.br/portfolio-2/

    Filter Code:

    <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>

    Code for displaying 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(); ?>

    Would anyone tell me how to make my filter work as intended?

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 5 months ago by paulo.bemvisto
  • This topic is not resolved
  • WordPress version: 3.8.1