Another if/else issue
-
I am getting an error say there is an unexpected ‘{‘. What I’m trying to do is say:
If the page has a featured image, use it in this div background
else
is any page or post, use this array.
Any ideas as to what I am doing wrong?
<?php if ( is_page() ) { ?> <?php global $post; ?> <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' ); ?> <div style="background: url(<?php echo $src[0]; ?> ) !important; min-height: 100%; background-size: cover !important; background-position: center !important; margin: auto; padding: 20px 0; max-width: 1000px;"> <?php } else ( is_page() || is_single() ) { ?> <?php $homeDiv = '<div id="wrapper-home">'; $homedueDiv = '<div id="wrapper-home2">'; $hometreDiv = '<div id="wrapper-home3">'; $allDivs = array(); array_push($allDivs, $homeDiv, $homedueDiv, $hometreDiv); $randomNumber = rand(0, count($allDivs) - 1); echo $allDivs[$randomNumber]; ?> <?php } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Another if/else issue’ is closed to new replies.