SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Mentor silver trophybronze trophy

    Join Date
    Feb 2008
    Location
    Preston, Lancashire
    Posts
    1,377
    Mentioned
    72 Post(s)
    Tagged
    1 Thread(s)

    WordPress Syntax If Statement

    I have a syntax issue with WP. I was wondering if anybody knew what the issue was and how I can solve this. I've already tried the codex subsository and I've found no obvious answer.

    Here is my code
    Code:
                               <?php if (get_post_meta($post->ID, 'PostImage') ) : ?>
                                    <div class="post-image">
                                        <a href="<?php the_permalink(); ?>">
                                            <img src='<?php echo get_post_meta($post->ID, 'PostImage', true); ?>' width="180px" />
                                        </a>
                                    </div>
                                <?php endif; ?>
    This works as normal. I wanted an else if on the end. The issue I have is that I want the listing to be full width is there is no image on the left-hand side. This can easily be achieved in CSS if I put an else or else if.

    Off Topic:


    WordPress must be doing well. CMS and WordPress forum section
    follow me on ayyelo, Easy WordPress; specializing in setting up themes!

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    http://fr.php.net/manual/en/control-...ive-syntax.php
    Code:
    <?php if (get_post_meta($post->ID, 'PostImage') ) : ?>
      <div class="post-image">
          <a href="<?php the_permalink(); ?>">
              <img src='<?php echo get_post_meta($post->ID, 'PostImage', true); ?>' width="180px" />
          </a>
       </div>
    <?php else : ?>
       ....
    <?php endif; ?>

  3. #3
    SitePoint Mentor silver trophybronze trophy

    Join Date
    Feb 2008
    Location
    Preston, Lancashire
    Posts
    1,377
    Mentioned
    72 Post(s)
    Tagged
    1 Thread(s)
    Thanks guido
    follow me on ayyelo, Easy WordPress; specializing in setting up themes!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •