Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Annoying Parse Error

Featured Replies

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

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

  • 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

  • Author

Brilliant thanks.

 

Ahhh so the problem was finishing the loops:

 

<?php endwhile; ?>

<?php endif; ?>

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

  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.