Missing endifs?
-
I am trying to troubleshoot the specimen Custom Category Template category.php given at the end of “Category Templates” (https://codeex.www.ads-software.com/Category_Templates)
The error message is:
“Parse error: parse error, unexpected $ in /usr/www/users/my_server/blog/wp-content/themes/my_theme/category.php on line 84”
I have, of course, only 83 lines.
There are no open braces (all the { are closed with }) but by my count there are four if present but only one endif.
Question 1: Could the three open IFs be the cause of the error?
Question 2: Is there anything else that can close an IF?
Question 3: If there really are three endifs missing, could somebody please suggest places where I could try putting them?
The affected section of code is:
<div id="content">
<?php if (have_posts()) : ?> // -------- FIRST IF
<div id="cattoc">
<ul>
<?php $this_category = get_category($cat);?>
<?php if ($this_category->category_parent == 0) { ?> // -------- SECOND IF
<li>
<a href="<?php echo get_category_link($cat); ?>" title="<?php echo $this_category->cat_name; ?>">
<?php echo $this_category->cat_name; ?></a>
<ul>
<?php $this_category->category_parent = $cat; ?>
<?php } else { ?>
<?php $parent_category = get_category($this_category->category_parent); ?>
<li>
<a href="<?php echo get_category_link($parent_category->cat_ID); ?>" title="<?php echo $parent_category->cat_name; ?>">
<?php echo $parent_category->cat_name; ?></a>
<ul>
<?php } ?>
<?php wp_list_cats('sort_column=name&optioncount=0&list=1&use_desc_for_title=0&child_of=' . $this_category->category_parent); ?>
</ul></li>
</ul></div>
<?php if ( $paged < 2 ) { // Do stuff specific to first page?> // --------- THIRD IF
<?php if ( is_category() ) : ?> // ------- FOURTH IF
<h2 id="category-name-header"><?php echo $cache_categories[$cat]->cat_name ?></h2>
<?php add_filter('category_description', 'wpautop'); ?>
<?php add_filter('category_description', 'wptexturize'); ?>
<div id="category-description">
<?php echo category_description(); ?>
</div>
<?php endif; ?> // --------- ONE AND ONLY ENDIFThe Category Templates entry is flagged as “in need of editing”. Once I get this thing working I will edit it but my php is not really up to closing the three open ifs all on my little own!
Any useful hints will be appreciated.
- The topic ‘Missing endifs?’ is closed to new replies.