Title: Category Exclusion&#8230; small Index.php Coding Problem &#8211;
Last modified: August 19, 2016

---

# Category Exclusion… small Index.php Coding Problem –

 *  Resolved [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/)
 * Hello,
 * I’ve been trying to code a query post into the [site’s](http://thechariots.org)
   index.php so that the ‘news’ category shows up in the ‘news feed’ – with all 
   other categories excluded. The category ID=1 for ‘news’.
 * This idea worked perfectly for me on another theme, but this time it throws up
   an ‘syntax error on line 25’ of Index.php – I could do with some expert advice
   on solving this. Maybe I need to sort out the line spacing, maybe a stray/missing
   bracket? Any tips on fixing this code would mean a lot.
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/page/2/?output_format=md)

 *  [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * (@dgwyer)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064363)
 * Can you use the pastebin so I can view your code.
 *  Thread Starter [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064375)
 * [http://pastebin.com/yPwdSE9X](http://pastebin.com/yPwdSE9X)
 *  [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * (@dgwyer)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064390)
 * Are you missing a semi-colon on line 19?
 *  Thread Starter [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064418)
 * I haven’t made a change to 19, as far as I’m aware. I’m happy to try inserting
   a semi-colon, but I’m not sure where to place it…
 * Any other suggestions?
 *  [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * (@dgwyer)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064423)
 * Try changing line 19 from:
 * `<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title()?
   ></a></h2>`
 * to:
 * `<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php 
   the_title() ?></a></h2>`
 * Also what does the syntax error say?
 *  Thread Starter [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064435)
 * Hi , and thanks for your help. The semi colon is now in place, but there has 
   been no change to the original problem unfortunately.
 * > Parse error: syntax error, unexpected T_ELSE in /home/content/d/o/u/douglasbell/
   > html/Chariots/wp-content/themes/gridfocus/index.php on line 25
 *  [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * (@dgwyer)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064437)
 * Also add a semi-colon after ‘the_title()’ on line 25 just for completion.
 * I see your problem now, your code is structured in the following way:
 *     ```
       if
         while
         endwhile
       else
       endif
       ```
   
 * Your problem is because there is no opening `if`. This might have been missed
   off when copying/pasting code?
 *  Thread Starter [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064444)
 * Hi,
 * do you mean another semi-colon on line 19? (as below)
 * > </h2>
 * I’m not sure how an opening ‘if’ has gone missing – having been very careful 
   with pasting, and unfortunately I’m not sure how to replace it exactly…
 * Many thanks again for your help…!
 *  Thread Starter [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064540)
 * I’ve spotted where the missing IF was… here is the original code from the top
   of the Index.php – I’m stuck on how to fix this still, so any help would be hugely
   appreciated. Learning by doing.
 *     ```
       <div id="filler" class="fix">
       	<div id="mainColumn">
       		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       		<div id="post-<?php the_ID(); ?>" class="post">
       				<div class="postMeta">
       				<p class="container">
   
       				</p>
       			</div>
       ```
   
 * _[Please post code snippets between backticks or use the code button.]_
 *  [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * (@dgwyer)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064545)
 * Try adding:
 * `<?php if (have_posts()) : ?>`
 * directly under the line:
 * `<?php query_posts('category=1'); ?>`
 *  Thread Starter [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064547)
 * Thanks David.
 * It seems to have resulted in a new error:
 * > Parse error: syntax error, unexpected $end in /home/content/d/o/u/douglasbell/
   > html/Chariots/wp-content/themes/gridfocus/index.php on line 46
 * Any thoughts?
 *  [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * (@dgwyer)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064548)
 * Could you put the whole files updated code on pastebin?
 *  Thread Starter [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064556)
 * Inndex.php as it is now [http://pastebin.com/SeLWVrpU](http://pastebin.com/SeLWVrpU),
   resulting in:
 * > Parse error: syntax error, unexpected $end in /home/content/d/o/u/douglasbell/
   > html/Chariots/wp-content/themes/gridfocus/index.php on line 46
 *  Thread Starter [douglasbell01](https://wordpress.org/support/users/douglasbell01/)
 * (@douglasbell01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064557)
 *  [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * (@dgwyer)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/#post-2064561)
 * There is now no matching `endif;’ directly before the line:
 * `<div id="paginateIndex" class="fix">`
 * This was present before.

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/page/2/?output_format=md)

The topic ‘Category Exclusion… small Index.php Coding Problem –’ is closed to new
replies.

## Tags

 * [gridfocus](https://wordpress.org/support/topic-tag/gridfocus/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 17 replies
 * 2 participants
 * Last reply from: [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/category-exclusion-small-indexphp-coding-problem/page/2/#post-2064570)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
