Support » Themes and Templates » Not sure how to use if function exists

Viewing 3 replies - 1 through 3 (of 3 total)
  • Would this work?

    <?php
    if (function_exists('plugin_options')) {
        <img src="<?php echo $options['logo']; ?>" alt="Logo" />
    } else {
        <a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    }
    ?>

    I’m pretty new at this so I’d love some advice

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

    You’re querying for an option, not for a function.

    Try this instead:

    <?php
    $options = get_option('plugin_options');
    if ( $options['logo'] ) { ?>
         <img src="<?php echo $options['logo']; ?>" alt="Logo" />
    <?php } else { ?>
         a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    <?php }
    ?>

    Fantastic! That worked like a charm, thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Not sure how to use if function exists’ is closed to new replies.