• Resolved douglasbell01

    (@douglasbell01)


    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]

Viewing 15 replies - 1 through 15 (of 17 total)
  • Can you use the pastebin so I can view your code.

    Thread Starter douglasbell01

    (@douglasbell01)

    Are you missing a semi-colon on line 19?

    Thread Starter douglasbell01

    (@douglasbell01)

    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?

    Thread Starter douglasbell01

    (@douglasbell01)

    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?

    Thread Starter douglasbell01

    (@douglasbell01)

    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…!

    Thread Starter douglasbell01

    (@douglasbell01)

    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'); ?>

    Thread Starter douglasbell01

    (@douglasbell01)

    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?

    Thread Starter douglasbell01

    (@douglasbell01)

    Inndex.php as it is now https://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

    (@douglasbell01)

    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)
  • The topic ‘Category Exclusion… small Index.php Coding Problem –’ is closed to new replies.