Created
October 26, 2011 11:29
-
-
Save lluisgerard/1316084 to your computer and use it in GitHub Desktop.
archive.php | Wordpress theme file part | Show just one category (parent category alone, or child categories alone)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $cat_obj = $wp_query->get_queried_object(); ?> | |
<?php | |
if( $cat_obj->parent ) { | |
// CATEGORIA FILL / Child category only | |
while ( have_posts() ) : the_post(); ?> | |
<?php include('post.php'); ?> | |
<?php endwhile; ?> | |
<?php } else { ?> | |
<?php | |
// CATEGORIA PARE / Parent category only | |
while ( have_posts() ) : the_post(); ?> | |
<?php | |
// Controlem que sempre sigui una categoria pare / a parent has no parent | |
$category = get_the_category(); | |
if ($category[0]->category_parent == 0) : ?> | |
<?php include('post.php'); ?> | |
<?php endif; ?> | |
<?php endwhile; ?> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment