-3
<?php if (get_the_author_meta('description')) {  ?>
    <?php
    $author_ID = get_the_author_meta('ID');
    $username = get_the_author_meta('display_name', $author_ID); ?>

    <div class="mm-author-box">
        <figure class="mm-author-box-avatar">
            <?php echo get_avatar($author_ID, 70); ?>
        </figure>
        <?php if ($author_ID === 4) { ?>
            <div class="mm-author-name">
                <a href="<?php echo "http://google.com" ?>"> <?php echo $username; ?> </a>
            </div>
            <div class="mm-author-bio">
                <?php echo get_the_author_meta('description'); ?>
            </div>
    </div>
    <?php } ?>
    <?php else { ?>
        <?php if ($author_ID === 9) { ?>
            <div class="mm-author-name">
                <a href="<?php echo "http://yahoo.com" ?>"> <?php echo $username; ?> </a>
            </div>
            <div class="mm-author-bio">
                <?php echo get_the_author_meta('description'); ?>
            </div>
        </div>
        <?php } ?>
<?php } ?>

It is a code to display author name and hyper link it. From the first if statement if author has a description then go inside Second if statement: if authors ID is 4 then execute the code below if not then Else, there is one extra div inside the else statement which is for <div class="mm-author-box"> which is outside the if statement. The problem is that when I put this code it breaks the page.. Only the header of the website loads and the content below it doesn't because i have placed this code in the php file which is a template for the page content. I think there is some syntax problem coz I used the code without else statement and it worked.

jaseon
  • 1
  • 1
  • Do you get any errors? ([enable error reporting PHP](http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) – Mathlight Feb 02 '16 at 10:44

3 Answers3

1

You missed to close a curly bracket in the end. Add below line as a last line and try :

<?php } ?>
AnkiiG
  • 3,468
  • 1
  • 17
  • 28
0

I don't know how strict that template engine is, but this could be the problem;

<div class="mm-author-bio">
            <?php echo get_the_author_meta('description'); ?>
        </div>
</div>
<?php } ?>

You're closing the div inside the if which was started outside the div. So , place that last </div> below the <?php } ?> and see if that helps

<?php if (get_the_author_meta('description')) {
    $author_ID = get_the_author_meta('ID');
    $username = get_the_author_meta('display_name', $author_ID); ?>

    <div class="mm-author-box">
        <figure class="mm-author-box-avatar">
            <?php echo get_avatar($author_ID, 70); ?>
        </figure>
        <?php if ($author_ID === 4) { ?>
            <div class="mm-author-name">
                <a href="<?php echo "http://google.com" ?>"> <?php echo $username; ?> </a>
            </div>
            <div class="mm-author-bio">
                <?php echo get_the_author_meta('description'); ?>
            </div>
        <?php } else if ($mh_author_ID === 9) { ?>
            <div class="mm-author-name">
                <a href="<?php echo "http://yahoo.com" ?>"> <?php echo $username; ?> </a>
            </div>
            <div class="mm-author-bio">
                <?php echo get_the_author_meta('description'); ?>
            </div>      
        <?php } ?>
    </div>
<?php } ?>

And as AnkiiG pointed out, you missed a closing tag, which I fixed without knowing while formatting my answer

Mathlight
  • 6,436
  • 17
  • 62
  • 107
0

Your if else structure is like this,

<?php if (get_the_author_meta('description')) { ?>

    <?php if ($author_ID === 4) { ?>

<?php } ?>
<?php else { ?>
    <?php if ($mh_author_ID === 9) { ?>

    <?php } ?>

You're not closing the first if statement

Mathlight
  • 6,436
  • 17
  • 62
  • 107
Rogin Thomas
  • 672
  • 8
  • 17