How to make a button image active?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5162 Reply
    James
    Guest

    I have image buttons on the sidebar, front page of my WordPress.org website. When the buttons are clicked it takes you to the appropriate page. However, the buttons are not active. In-other-words, they don’t actually press down like a real button when you click them with the mouse. How do I make these buttons active?

    Regards,
    James E.

    #5163
    Ron
    Keymaster

    You could use PHP Code Widget and do something like this:

    Example:

    <?php
    global $wp_query;
    $current_ID = $wp_query->post->ID;
    
    // Button 1
    if ( $current_ID == 10 )
         echo '<a href="https://ronangelo.com"><img src="https://ronangelo.com/button1_active.jpg" /></a>';
    else
         echo '<a href="https://ronangelo.com"><img src="https://ronangelo.com/button1_normal.jpg" /></a>';
    
    // Button 2
    if ( $current_ID == 15 )
         echo '<a href="https://ronangelo.com"><img src="https://ronangelo.com/button2_active.jpg" /></a>';
    else
         echo '<a href="https://ronangelo.com"><img src="https://ronangelo.com/button2_normal.jpg" /></a>';
    
    ?>

    In the example, numbers 10 and 15 are the post id of your target post. The example above is for 2 link buttons. You’re going to do the code for all your link buttons.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: How to make a button image active?
Your information: