Display different post-typ if the featured image exist or not

Hey I have a problem with my php code in wordpress. I want to have a different section class if there is a image or not. So I can make the text central if there is non image and make it float to right if there is.

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<?php if(has_post_thumbnail() ); ?>
    <section class="post">
        <?php the_post_thumbnail('full'); ?>
        <div class="posts-data">
            <h2><?php the_title(); ?></h2>
            <p><?php the_excerpt(); ?></p>
        </div>
    </section>
<?php else: ?>
    <section class="post-no-img">
        <h2><?php the_title(); ?></h2>
        <p><?php the_excerpt(); ?></p>
    </section>
<?php endif; ?>

<?php endwhile; else: ?>

<p>There are no post or pages</p>

<?php endif; ?>

I get this worning:

Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\Fortagsida\wp-content\themes\foretagblog\front-page.php on line 12

Line 12 is .

Solutions

You probably want to put ":" for the second if

In line 3, it should be <?php if(has_post_thumbnail() ): ?> (: instead of ;)

Similar questions

Wordpress different featured image size for different post types
You can enable featured images for posts and set their size by using the following code in your function.php file: but this sets the image size globally for any post types. Im using wordpress 3.0 and have created my own custom post type. Is it possible to apply a different featured thumbnail sizes for different post types? Thanks Scott
"Use as featured image" not working , "Set Featured Image" hangs. GoDaddy Issue
What my site runs on: What happens when i click use as featured image ? What I tried The problem was on 3.4.1 so i updated it to 3.4.2 ( Issue not resolved ) Changed the theme to the basic twenty ten ( Issue not resolved ) Wordpress support forums seem to sway towards the fact that its a wordpress core code issue and not an issue with the themes.
Dynamic Featured Image - WordPress - is not getting the first featured image
I've installed the latest Dynamic Featured Image 3.1.2 and when I try to just print out the array of featured images on the page I only get Featured Image 2 and onward. Even though I've added more than one Featured image it only shows from Featured Image 2 and on in the array. Did I miss something else that I need to do?
Posts without featured image using other post's featured image
I am using the following code (see bottom) to display a custom post called 'artists'. I am also using <?php if (has_post_thumbnail( $post->ID ) ) so I can set the background of a div using the post thumbnail (I don't think this is the problem). I want to display all of the posts on one page so use 'numberposts' => -1,. I have noticed that ...
Blog page featured image being overridden by blog post featured image
On my Wordpress blog page (home.php) template, I'm trying to display the featured image set for that page at the top, then the content archive grid underneath. However, instead of displaying the featured image I set for the page, the first blog post's featured image is displayed instead. Additionally (related), if I remove the first blog post's fea...
If custom image header does not exist display text header
I've added a theme options page to my site (in my functions.php file): My header.php contains this code, which displays the Featured Image as the banner. If a Featured Image isn't provided it uses the uploaded image banner from the custom image header. My question is, how can I modify this code to output an h1 text header (i.e. bloginfo('name');) i...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.