• Resolved janustudios

    (@jojithedevil)


    Hi there all i am using a photo plugin the thing is that i am trying to make my own conditional statement where i am trying to do is that

    i want to make these two statements in a conditional format by using these two statements

    IF

    <?php if ( function_exists( 'userphoto' ) ) { userphoto($posts[0]->post_author); } ?>

    ELSE

    <img src="<?php bloginfo('template_directory'); ?>/images/blank_avatar_176x132.gif" width="132" height="176" />

    How do i make this so i get if fucntion or if its not available i get to show my default avatar image…

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • What’s wrong with using:

    <?php if ( function_exists( 'userphoto' ) ) :
    userphoto($posts[0]->post_author);
    else :?>
    <img src="<?php bloginfo('template_directory'); ?>/images/blank_avatar_176x132.gif" width="132" height="176" />
    <?php endif;?>
    Thread Starter janustudios

    (@jojithedevil)

    Thanks a millions esmi, i just didnt had the concepts of making conditional statements… but this isnt solving out the problem because the if there is not photo it shows nothing a simple white n i guess thats because we are using if plugin exist function …

    what i need is that

    if photo exist or else
    else :?>
    <img src="<?php bloginfo('template_directory'); ?>/images/blank_avatar_176x132.gif" width="132" height="176" />
    <?php endif;?>

    just like where you told above if function extist…

    <?php if ( function_exists( ‘userphoto’ ) ) :
    userphoto($posts[0]->post_author);
    else :?>
    <img src=”<?php bloginfo(‘template_directory’); ?>/images/blank_avatar_176x132.gif” width=”132″ height=”176″ />
    <?php endif;?>

    Try:

    <?php if ( function_exists( 'userphoto' && userphoto($posts[0]->post_author != '') ) :
    userphoto($posts[0]->post_author);
    else :?>
    <img src="<?php bloginfo('template_directory'); ?>/images/blank_avatar_176x132.gif" width="132" height="176" />
    <?php endif;?>
    Thread Starter janustudios

    (@jojithedevil)

    Its breaking theme… ?? it says error on line 32 which is the line

    Line 32
    <?php if ( function_exists( 'userphoto' && userphoto($posts[0]->post_author != '') ) :

    From your follow code the first line is breaking theme…

    <?php if ( function_exists( 'userphoto' && userphoto($posts[0]->post_author != '') ) :
    userphoto($posts[0]->post_author);
    else :?>
    <img src="<?php bloginfo('template_directory'); ?>/images/blank_avatar_176x132.gif" width="132" height="176" />
    <?php endif;?>

    I can see it! Try:

    <?php if ( function_exists( 'userphoto') && userphoto($posts[0]->post_author != '') :
    userphoto($posts[0]->post_author);
    else :?>
    <img src="<?php bloginfo('template_directory'); ?>/images/blank_avatar_176x132.gif" width="132" height="176" />
    <?php endif;?>
    Thread Starter janustudios

    (@jojithedevil)

    Sorry esmi, ??

    Its again breaking themes the error comes at line 32 which is the first line of your code… pasted in dreamweaver to see where error occurs the first line’s <?php and the else :?> are highlighted in red…

    <?php if ( function_exists( 'userphoto') && userphoto($posts[0]->post_author != '') :
    userphoto($posts[0]->post_author);
    else :?>
    <img src="<?php bloginfo('template_directory'); ?>/images/blank_avatar_176x132.gif" width="132" height="176" />
    <?php endif;?>

    Sorry about this. I’ll get the bracket placement right eventually…

    <?php if ( function_exists( 'userphoto') && userphoto($posts[0]->post_author) != '') :
    userphoto($posts[0]->post_author);
    else :?>
    <img src="<?php bloginfo('template_directory'); ?>/images/blank_avatar_176x132.gif" width="132" height="176" />
    <?php endif;?>

    Also bear in mind that I have no idea what userphoto($posts[0]->post_author) normally returns.

    Thread Starter janustudios

    (@jojithedevil)

    AND YOU GOTTTTT ITTTTT!!!!!!!!! Esmi so much thankyou…. Thanks a tonsss….. God bless you simply… thats so cool… that u solved this big prob in munites!!! Thanks a tons… I would luv to return a favor via my blogs in future… thanks alot very much

    Glad to hear that we got there in the end. Seems like you’ve been passing the favour on and trying to help others on the forums already. ??

    Thread Starter janustudios

    (@jojithedevil)

    ?? Thanks i do look forward to help others and expand my knowledge and experience… just like you… ?? Thanks a tons…

    You saved the Day…!!! ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘HELP… If else statement not working…!’ is closed to new replies.