Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Pete on "Conditional based on whether the current cat has a child category"

$
0
0

I'm having trouble getting the syntax correct?

<?php // conditional based on whether the current cat has child categories... or not
$cat_id = get_query_var('cat');
$catlist = wp_list_categories('echo=0&orderby=id&title_li=&child_of=' . $cat_id); ?>
<?php if (get_categories('parent=' . $cat_id)) { ?>
<h1>The current cat has a child cat</h1>
<?php else {  ?>
<p>The current cat doesn't have a child cat</p>
<?php } ?>

I think it's the end part...

<?php else {  ?>
<p>The current cat doesn't have a child cat</p>
<?php } ?>

Thanks... I'm sooo bad at php!

Pete


Viewing all articles
Browse latest Browse all 8245

Trending Articles