douglasbell01
Member
Posted 1 year ago #
Hello,
I've been trying to code a query post into the site's 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. Please use the pastebin]
Can you use the pastebin so I can view your code.
douglasbell01
Member
Posted 1 year ago #
Are you missing a semi-colon on line 19?
douglasbell01
Member
Posted 1 year ago #
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?
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?
douglasbell01
Member
Posted 1 year ago #
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
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?
douglasbell01
Member
Posted 1 year ago #
Hi,
do you mean another semi-colon on line 19? (as below)
<h2>" title="<?php the_title(); ?>"><?php the_title(); ?></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...!
douglasbell01
Member
Posted 1 year ago #
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.]
Try adding:
<?php if (have_posts()) : ?>
directly under the line:
<?php query_posts('category=1'); ?>
douglasbell01
Member
Posted 1 year ago #
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?
Could you put the whole files updated code on pastebin?
douglasbell01
Member
Posted 1 year ago #
Inndex.php as it is now 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
douglasbell01
Member
Posted 1 year ago #
There is now no matching `endif;' directly before the line:
<div id="paginateIndex" class="fix">
This was present before.
douglasbell01
Member
Posted 1 year ago #
David, you're a legend! I was playing with the endif, when my concentration was broken by a phone call, so must have cut it and not put it back!
Index.php now working perfectly (having changed the quesry slightly to:
<?php query_posts('category_name=news'); ?>
Link to modified Gridfocus Index.php file for other users: http://pastebin.com/LEUcwwC7
Glad you got it sorted. :)
Can you mark the thread as resolved. Thanks.