Hi, I got the syntax error refering to line 108 The relevant section of the code is shown below, the said line 108 is marked.Please help correct my syntax.Thank you <?php foreach( (array) $terms as $term){ echo wp_get_attachment_image( $term->image_id, 'thumb' ); echo $term->name; [LINE108] echo '<div style="margin: 0 10px 10px 0; float: left"><a href="’ esc_url( get_term_link( $term, $term->taxonomy ) );’"><img src=" wp_get_attachment_image( $term->image_id, 'thumb' );"></a> ?>
Try this echo '<div style="margin: 0 10px 10px 0; float: left"><a href="’. esc_url( get_term_link( $term, $term->taxonomy ) ).’"><img src="'.wp_get_attachment_image( $term->image_id, 'thumb' ).'"></a> PHP: looks like you just copied and pasted a bunch of code together without checking anything.
Thanks plussy. Yes, I was trying to merge a bunch of codes, and ran into that problem. I am not very familiar with Php or Html. I have implemented your suggesion, but it seems there is still an error in the code. Now it is says "Parse error: syntax error, unexpected $end in line 103". Line 103 is the last line of the php file. It contains no code. Pls help. <div class="itembox"> <h1>"Testing something"</h1> <div class="itemboxinner"> <?php foreach( (array) $terms as $term){ echo '<div style="margin: 0 10px 10px 0; float: left"><a href="’. esc_url( get_term_link( $term, $term->taxonomy ) ).’"><img src="'.wp_get_attachment_image( $term->image_id, 'thumb' ).'"></a>; ?> </div><!-- end itembox innner --> </div><!-- end itembox --> <?php get_footer(); } /* ============================================================================= -- END FILE ========================================================================== */
try this then. <div class="itembox"> <h1>"Testing something"</h1> <div class="itemboxinner"> <?php foreach( $terms as $term){ echo '<div style="margin: 0 10px 10px 0; float: left"><a href="'. esc_url( get_term_link( $term, $term->taxonomy ) ).'"><img src="'.wp_get_attachment_image( $term->image_id, 'thumb' ).'"></a>'; } ?> </div><!-- end itembox innner --> </div><!-- end itembox --> <?php get_footer(); } /* ============================================================================= -- END FILE ========================================================================== */ ?> PHP:
Dear plussy, Thanks for your help. That almost worked. The output is a shell with 'x' in the middle, no images. However, the code below gave me the images. Scattered all over. Other than the way the 'echo' statements are broken, I wonder what the difference is, and why the code above is returning shells and no images. <?php foreach( (array) $terms as $term){ echo '<div style="margin: 0 10px 10px 0; float: left">'; echo '<a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'thumb' ) . '</a>'; echo '</li>'; } ?> PHP: My ultimate destination is to show the images, and arrange them somewhat, like in a grid. Thank you
foreach( (array) $terms as $term) ... Code (markup): Good grief, casting in PHP!? A weak typed language? Awful.