• Resolved gwenm

    (@gwenm)


    Hello,I have a problem in Parse error that I can not correct…

    My error:
    Parse error: syntax error, unexpected T_ENDWHILE in /web/doclibre/www/wp-content/themes/lifestyle_20/category.php on line 36

    on line 36 is <?php endwhile; else: ?>

    My code:

    <?php get_header(); ?>
    
    <div id="content">
    
    	<div id="contentleft">
    
    		<div class="postarea3">
    
    		<?php include(TEMPLATEPATH."/breadcrumb.php");?>
    			<?php echo category_description( $category_id ); ?>
    
    if (have_posts()) {
      while (have_posts()) {
        the_post();
      }
    
                    <?php
    
                    $cats = get_categories();
                    foreach ($cats as $cat) {
    
                    query_posts('showposts=10&cat=718-CATEGORIE'.$cat->cat_ID);
    
                ?>
    
    			 <div class="article4">
    
    			<?php the_excerpt(); ?>
    			</div>
    
    		 <?php endwhile; else: ?> 
    
    			<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
    			<p><?php if(function_exists('wp_simple_pagination')) {
        wp_simple_pagination();
    } ?></p>
    
    		</div>
    
    	</div>
    
    <?php include(TEMPLATEPATH."/sidebar.php");?>
    
    </div>
    
    <!-- The main column ends  -->
    
    <?php get_footer(); ?>

    Thank you very much for help ??

Viewing 14 replies - 1 through 14 (of 14 total)
  • Remove <?php on line 17.

    Thread Starter gwenm

    (@gwenm)

    Thanks, but it does not work…

    In what way doesn’t it work? It’s plainly incorrect.

    Thread Starter gwenm

    (@gwenm)

    I remove <?php on line 17 but it does not work…

    <?php get_header(); ?>
    
    <div id="content">
    
    	<div id="contentleft">
    
    		<div class="postarea3">
    
    		<?php include(TEMPLATEPATH."/breadcrumb.php");?>
    			<?php echo category_description( $category_id ); ?>
    
    if (have_posts()) {
      while (have_posts()) {
        the_post();
      }
    
                    $cats = get_categories();
                    foreach ($cats as $cat) {
    
                    query_posts('showposts=10&cat=718-CATEGORIE'.$cat->cat_ID);
    
                ?>
    
    			 <div class="article4">
    
    			<?php the_excerpt(); ?>
    			</div>
    
    		 <?php endwhile; else: ?> 
    
    			<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
    			<p><?php if(function_exists('wp_simple_pagination')) {
        wp_simple_pagination();
    } ?></p>
    
    		</div>
    
    	</div>
    
    <?php include(TEMPLATEPATH."/sidebar.php");?>
    
    </div>
    
    <!-- The main column ends  -->
    
    <?php get_footer(); ?>

    But what error message are you getting now?

    Thread Starter gwenm

    (@gwenm)

    My error:
    Parse error: syntax error, unexpected T_ENDWHILE in /web/doclibre/www/wp-content/themes/lifestyle_20/category.php on line 36

    How can you be getting an error on the same line if you removed the line I suggested?

    Thread Starter gwenm

    (@gwenm)

    I dont now .. I just remove <?php on line 17 and the error remains the same..

    Are you trying to use two loops in this template file? If so, you shouldn’t be using query_posts() for the second loop but should use get_posts() or WP_Query() instead.

    there is a <?php missing before if (have_posts()) { in line 12;

    but the whole code does not make any sense;
    the loop is not started properly, the query is not followed by a loop etc.

    can you describe what you are trying to do with the code?

    https://codex.www.ads-software.com/The_Loop

    Thread Starter gwenm

    (@gwenm)

    I want to display a specific category (category id=718)…

    category.php should be left alone/unedited to show all possible categories (which it will do automatically);

    if you want to show one category with a special layout, consider to create a category template; https://codex.www.ads-software.com/Category_Templates

    if you want that a page should show posts of a category, create a page template; https://codex.www.ads-software.com/Pages#Creating_Your_Own_Page_Templates
    for which you could start with a copy of index.php, add the necessary code at the top, and add a query before the loop;
    example based on your posted code: https://pastebin.com/MfyCMfgV

    (more-or-less a guess, as I am still not sure what you are trying to achieve)

    related Codex chapters:
    https://codex.www.ads-software.com/Theme_Development
    https://codex.www.ads-software.com/The_Loop
    https://codex.www.ads-software.com/Function_Reference/query_posts

    where do you want to show that particular category?

    Thread Starter gwenm

    (@gwenm)

    You understand ;), I want to show one category with a special layout.
    I am French and I have difficulties in translating the codex. Thanks for the links, I’ll look at it.

    Thread Starter gwenm

    (@gwenm)

    Success:

    <?php get_header(); ?>
    
    <div id="content">
    
    	<div id="contentleft">
    
    		<div class="postarea3">
    
    		<?php include(TEMPLATEPATH."/breadcrumb.php");?>
    			<?php echo category_description( $category_id ); ?>
    
    		<?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    			 <?php get_the_category_by_ID( 718 ); ?> 
    
    			 <div class="article4">
    
    			<?php the_excerpt(); ?>
    			</div>
    
    			 <?php endwhile; else: ?>
    
    			<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
    			<p><?php if(function_exists('wp_simple_pagination')) {
        wp_simple_pagination();
    } ?></p>
    
    		</div>
    
    	</div>
    
    <?php include(TEMPLATEPATH."/sidebar.php");?>
    
    </div>
    
    <!-- The main column ends  -->
    
    <?php get_footer(); ?>

    Thank you very much ^^

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Parse error’ is closed to new replies.