I am getting the following error:
Parse error: syntax error, unexpected ‘<‘ in /home/u7mtb69/public_html/wpsitehrhhw/wp-content/themes/hrhhw.1.1/functions.php on line 1201
I am trying to add meta boxes to a custom post section in my function.php file.
The file works great, until I add the <div> container, then I get an error – but the container looks correct.
Can anyone tell me what the issue is?
// Add WHEELS meta boxes
add_action( 'add_meta_boxes' , 'wheel_meta_boxes' );
function wheel_meta_boxes() {
add_meta_box(
'wheel_info',
__( 'Wheel Info'),
'wheel_info_div',
'wheels'
);
}
function wheel_info_div( $post ) {
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), 'wheel_noncename' );
}
// WHEELS fields for data entry
<div>
<label for="tire_code">
<?php _e("Tire Code");?>
</label>
<input type="text" name="tire_code" value="<?php echo get_post_meta($post->ID, 'tire_code', true);?>" />
<br>
<label for="tire_name">
<?php _e("Tire Name");?>
</label>
<input type="text" name="tire_name" value="<?php echo get_post_meta($post->ID, 'tire_name', true);?>" />
<br>
<label for="tire_bname">
<?php _e("Tire Brand");?>
</label>
<input type="text" name="tire_bname" value="<?php echo get_post_meta($post->ID, 'tire_bname', true);?>" />
<br>
<input type="button" value="Create" id="create" />
<input type="button" value="Replace" id="replace" />
</div>
// NEXT
// END
?>
The problem is that you put HTML inside a PHP block. Don’t do that.
You must remember that PHP and HTML are completely distinct. There is no relationship whatsoever, other than that the HTML your browser sees is the result of a PHP interpreter running your PHP script (which may include some hard-coded HTML to keep in the output, like your
<div>). So when you see a PHP error, it’s not going to be HTML at fault.Wrong:
Right: