Skip to content
Advertisement

PHP condition with HTML/PHP putput

I running WordPress site and I want to show something only if post format is quote. I have following code but it give fatal error:

<?php if ( 'quote' == get_post_format() ) {
    
print '<blockquote>
<font size = "5"><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, '1QUOTEEEEEEEEEEEEEEEEEEE', true);
wp_reset_query();
?></font>
  <span class="author"><i><a href="<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, '3RLLLLLLLLLLLLLLLLLLLLLL', true);
wp_reset_query();
?>"><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, '2AUTORRRRRRRRRRRRRRRRR', true);
wp_reset_query();
?></a></i></span>
</blockquote>';

} ?>

Advertisement

Answer

It looks like you have a syntax error in your code. Try simplifying your code as follows:

<?php 
if ( 'quote' == get_post_format() ) {
    global $wp_query;
    $postid = $wp_query->post->ID;
?>

<blockquote>
    <font size = "5">
    <?php 
        echo get_post_meta($postid, '1QUOTEEEEEEEEEEEEEEEEEEE', true);
    ?>
    </font>

    <span class="author">
        <i>
            <a href="<?php echo get_post_meta($postid, '3RLLLLLLLLLLLLLLLLLLLLLL', true);?>">
                <?php
                    echo get_post_meta($postid, '2AUTORRRRRRRRRRRRRRRRR', true);
                ?>
            </a>
        </i>
    </span>
</blockquote>
<?php
    wp_reset_query();
} 

If you still get the Fatal error, share the error with us. It will help point us in the right direction.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement