If Query In Sidebar

I’m trying to create a query that

IF there is a value in the ‘FeaturedQuote’ custom field, then this shows

Read More
<h3 class="featuredquote"><blockquote><span class="bqstart">“</span><?php
    global $wp_query;
    $postid = $wp_query->post->ID;
    echo get_post_meta($postid, 'FeaturedQuote', true);
    wp_reset_query();
    ?>
<span class="bqend">”</span></blockquote>
</h3>

IF NOT, this shows:

<img src="<?php
    global $wp_query;
    $postid = $wp_query->post->ID;
    echo get_post_meta($postid, 'InsertFullImg', true);
    wp_reset_query();
    ?>">

I cant get it right!

Thanks

Related posts

1 comment

  1. Assign the return value of the first check to a variable, and test if there is something in it:

    if ( $quote = get_post_meta( get_the_ID(), 'FeaturedQuote', TRUE ) )
    {
    ?><h3 class="featuredquote"><?php the_title(); ?></h3>
    <blockquote><span class="bqstart">&#8220;</span><?php
        echo $quote;
        ?>
    <span class="bqend">&#8221;</span></blockquote>
    <?php
    }
    elseif ( $img = get_post_meta( get_the_ID(), 'InsertFullImg', TRUE ) )
    {
        echo "<img src='$img' alt=''>";
    }
    

    Note, a <h3> cannot be the parent of a <blockquote>. Headlines can contain inline elements only.

Comments are closed.