Forums

[resolved] how can i put an HREF inside an IF ELSE ? (3 posts)

  1. petergus
    Member
    Posted 9 months ago #

    im using justin tadlocks sliding plugin which gives the original call like so

    <a class="open" title="
    <?php _e('Open panel', 'sliding-panel'); ?>">
    <?php _e('Open <span class="arrow">↓</span>', 'sliding-panel'); ?>
    </a>

    and i want make something like this -

    <?php
    if ( is_user_logged_in() ) {
        echo '<a href="<?php echo wp_logout_url( get_permalink() ); ?>"
    title="Logout">Logout</a>';
    } else {
        echo '
    <a class="open" title="
    <?php _e('Open panel', 'sliding-panel'); ?>">
    <?php _e('Open <span class="arrow">↓</span>', 'sliding-panel'); ?>
    </a>';
    }
    ?>

    however its getting an href inside a if else statement, its just not doing it!!

    any ideas here, i thought probably i can build a custom function with the URL and put that in, but ive no idea how to go about that.

    thanks for any tips!!

  2. alchymyth
    The Sweeper
    Posted 9 months ago #

    try a different approach by changing from php to html and back:

    <?php
    if ( is_user_logged_in() ) { ?>
        <a href="<?php echo wp_logout_url( get_permalink() ); ?>"
    title="Logout">Logout</a>
    <?php } else { ?>
    <a class="open" title="
    <?php _e('Open panel', 'sliding-panel'); ?>">
    <?php _e('Open <span class="arrow">↓</span>', 'sliding-panel'); ?>
    </a>
    <?php }
    ?>
  3. petergus
    Member
    Posted 9 months ago #

    YES!
    thank you!!
    you have helped me over a 'learning php hurdle' ;D

Reply

You must log in to post.

About this Topic

Tags