• I’m trying to code a condition to use different ad images to category specific pages in the header file but I’m getting errors:

    Parse error: syntax error, unexpected ‘<‘ in /home/nerej/public_html/wp-content/themes/nerej/header.php on line 70.

    Line 70 starts with the first “<div class”

    Here is the code:

    <?php
    if ( in_category( 'connecticut' )) {
    		if(get_field('con_block_top', 'option')) {
    				<div class="bottom-header">
    					<div class="container">
    						<a target = '_blank' href="<?php the_field('con_block_top_link', 'option'); ?> "><img src="<?php the_field('con_block_top', 'option'); ?>" /></a>
    					</div>
    				</div>
    			} ?>
    } elseif ( in_category( 'shopping-centers' )) {
    		if(get_field('con_block_top', 'option')) {
    				<div class="bottom-header">
    					<div class="container">
    						<a target = '_blank' href="<?php the_field('con_block_top_link', 'option'); ?> "><img src="<?php the_field('con_block_top', 'option'); ?>" /></a>
    					</div>
    				</div>
    			 } ?>
    } else {
    		if(get_field('nerej_block_top', 'option')) {
    				<div class="bottom-header">
    					<div class="container">
    						<a target = '_blank' href="<?php the_field('nerej_block_top_link', 'option'); ?> "><img src="<?php the_field('nerej_block_top', 'option'); ?>" /></a>
    					</div>
    				</div>
    			 } ?>
    }
    ?>

Viewing 1 replies (of 1 total)
  • You’ve forgotten the opening and closing PHP tags in many places in this code snippet:

    <?php
    if ( in_category( 'connecticut' )) {
      if(get_field('con_block_top', 'option')) { ?>
        <div class="bottom-header">
          <div class="container">
            <a target = '_blank' href="<?php the_field('con_block_top_link', 'option'); ?> "><img src="<?php the_field('con_block_top', 'option'); ?>" /></a>
          </div>
        </div>
      <?php } ?>
    <?php } elseif ( in_category( 'shopping-centers' )) {
      if(get_field('con_block_top', 'option')) { ?>
        <div class="bottom-header">
          <div class="container">
            <a target = '_blank' href="<?php the_field('con_block_top_link', 'option'); ?> "><img src="<?php the_field('con_block_top', 'option'); ?>" /></a>
          </div>
        </div>
      <?php } ?>
    <?php } else {
      if(get_field('nerej_block_top', 'option')) { ?>
        <div class="bottom-header">
          <div class="container">
            <a target = '_blank' href="<?php the_field('nerej_block_top_link', 'option'); ?> "><img src="<?php the_field('nerej_block_top', 'option'); ?>" /></a>
          </div>
        </div>
    <?php } ?>

    <?php } ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Help with If/else code in Header’ is closed to new replies.