Simple PHP question (1 line of code).

Discussion in 'PHP' started by mrktjunior, Jan 1, 2012.

  1. #1
    Hi,

    How can I make this code:

    $icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
    Code (markup):
    link to the Wordpress post?


    The code above displays an icon on a thumbnail on my homepage (wordpress based). But the icon is not "active", I want to make it so if the user clicks on the icon it takes him to that specific post.

    thanks.
     
    mrktjunior, Jan 1, 2012 IP
  2. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #2
    Try:
    $icon = '<a href="' . get_permalink($post->ID) . '"><span class="' . get_post_format($post->ID) . '-icon"></span></a>';
    PHP:
     
    Alex Roxon, Jan 1, 2012 IP
  3. mrktjunior

    mrktjunior Well-Known Member

    Messages:
    171
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    115
    #3
    Excellent! Thanks a lot.
     
    mrktjunior, Jan 1, 2012 IP