WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Using "if statement" to echo value from database and transform into an image (2 posts)

  1. Nick
    Member
    Posted 3 years ago #

    HI,

    I got my author profiles extended. They can say from which country they come. It is either The Netherlands or Germany (dropdown box).

    Now I want to echo this value into the author page and turn either 'Netherlands' or 'Germany' into an image vlag.

    I tried to do it with the if statement, so far I got:

    <?php if( get_cimyFieldValue(get_the_author_ID(), 'LAND', treu) == 'Nederland' ) { ?>
    <div id="vlag"><img src="<?php bloginfo('template_directory'); ?>/images/nl-flag-small.png" alt="Deze tuin bevindt zich in Nederland" title="In Nederland"/></div>
    <?php } else { ?>
    
    <div id="vlag"><img src="<?php bloginfo('template_directory'); ?>/images/de-flag-small.png" alt="Deze tuin bevindt zich in Duitsland" title="In Duitsland"/></div>
    
    <?php }
    ?>

    Is there someone who can help me get on the right track? I just don;t see it at the moment. Tnx in advance!

  2. Nick
    Member
    Posted 3 years ago #

    Done it! Couldn't let it go actually xD

    For future reference:

    function rev_vlag() {
    $LAND = get_cimyFieldValue(get_the_author_ID(), 'LAND');
    
    if ( $LAND == " Nederland" ) {
    	echo ' <img src="http://www.nickmagnus.com/hettuinpadop/wp-content/themes/revolution/images/nl-flag-small.png"/> ';
    }
    
    if ( $LAND == "Deutschland" ) {
    	echo ' <img src="http://www.nickmagnus.com/hettuinpadop/wp-content/themes/revolution/images/de-flag-small.png"/> ';
    }
    }

    This in the functions.php file.

    <div id="vlag"><?php rev_vlag(); ?></div>
    This on the authors page.

Topic Closed

This topic has been closed to new replies.

About this Topic