October 1, 201015 yr Hey guys, This is the code I have in the PHP file: <?php /*Template Name: Portfolio - Single*/ ?> <?php get_header(); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_content('Read the rest of this entry »'); ?> <?php $custom = get_post_custom($post->ID); $customer = $custom["client"][0]; $website_url = $custom["website_url"][0]; ?> <div class="details"> <h3>Details</h3> <div>Client: <span><?=$customer?></span></div> <div>URL: <span><a href="<?=$website_url?>"><?=$website_url?></a></span></div> <div class="services"><?php echo get_the_term_list( $post->ID, 'servicesRendered', 'Services Rendered: <ul><li>','</li><li>','</li></ul>' ); ?> </div> </div> <?php get_footer(); ?> The error I am getting is below. Any ideas what the problem is? Parse error: syntax error, unexpected $end in /home/colloss1/public_html/wp-content/themes/alihitch/single-portfolio.php on line 29 Thanks, Ali
October 1, 201015 yr <?php /*Template Name: Portfolio - Single*/ ?> <?php get_header(); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_content('Read the rest of this entry »'); ?> <?php $custom = get_post_custom($post->ID); $customer = $custom["client"][0]; $website_url = $custom["website_url"][0]; ?> <div class="details"> <h3>Details</h3> <div>Client: <span><?=$customer?></span></div> <div>URL: <span><a href="<?=$website_url?>"><?=$website_url?></a></span></div> <div class="services"><?php echo get_the_term_list( $post->ID, 'servicesRendered', 'Services Rendered: <ul><li>','</li><li>','</li></ul>' ); ?> </div> </div> <?php endwhile; ?> <?php endif; ?> <?php get_footer(); ?>
October 1, 201015 yr Author Thanks, New error: Parse error: syntax error, unexpected T_ENDIF in /home/colloss1/public_html/wp-content/themes/alihitch/single-portfolio.php on line 28
October 1, 201015 yr Author Brilliant thanks. Ahhh so the problem was finishing the loops: <?php endwhile; ?> <?php endif; ?>
October 1, 201015 yr Yeah. They are alternative control structures... pretty annoying in my opinion, i prefer curly braces as my IDE will match them up and auto tab them. Most open source template systems use them now as they are said to be easier for designers and people with less programming knowledge to understand. http://www.php.net/manual/en/control-structures.alternative-syntax.php You can see on that page they also have 'else', so in your code you could put... <?php endwhile; ?> <?php else: ?> <p>There are no posts to display.</p> <?php endif; ?>
October 1, 201015 yr Author Over my head for the time-being I will get to grips with PHP one day! Thanks for your help
Create an account or sign in to comment