WordPress.org

Ready to get started?Download WordPress

Forums

Need image shorcode with href and alt (5 posts)

  1. mmhabits
    Member
    Posted 3 years ago #

    In every post, I need to add the following html/javascript code, which includes 3 images with a rolloever effect:

    <p style="text-align: center;">
    <a rel="nofollow" href="/go/link"><img src="/files/button1_o.png"
     title="enter text here" alt="text here" name="enter text here"
     width="130" height="47" border="0" id="enter text here"
    class="nohover"><img src="/files/button1.png" alt="enter text here"
     name="enter text here" width="130" height="47" border="0" id="enter
    text here" class="hover"></a> 
    
    <a rel="nofollow" href="/go/link"><img
     src="/files/button2_o.png" title="enter text here" alt="enter text
     here" name="enter text here" width="130" height="47" border="0"
    id="enter text here" class="nohover"><img src="/files/button2.png"
    alt="enter text here" name="enter text here" width="130" height="47"
    border="0" id="order" class="hover"></a> 
    
    <a rel="nofollow" href="/go
    /link"><img src="/files/button3_o.png" title="enter text here"
    alt="enter text here" name="enter text here" width="130" height="47"
    border="0" id="play" class="nohover"><img src="/files/button3.png"
    alt="enter text here" name="enter text here" width="130" height="47"
    border="0" id="enter text here" class="hover"></a>
    </p>

    It's quite cumbersome to do this in every post, and am trying to figure out how to do this with a short code. The images are always the same, but the alt/title text change, along with the href link.

    Is there a way to do this with a shortcode? Maybe something like

    [images link="http://thelink.com" alt="alt text"]

    Thanks!

  2. elfin
    Moderator
    Posted 3 years ago #

    if it has to go on every page, wouldn't putting in the theme be better?

  3. mmhabits
    Member
    Posted 3 years ago #

    Maybe, not sure. Each page that its on has a different href and alt text. I just need to reuse the same images. It also has to be displayed after about the first 300 characters.. but that differs, so the image has to be manually placed.

  4. elfin
    Moderator
    Posted 3 years ago #

    ahh got you.

    There is a plugin somewhere that allows you to construct your own shortcodes, or you could write one yourself easily enough:
    http://codex.wordpress.org/Shortcode_API

  5. mmhabits
    Member
    Posted 3 years ago #

    Cool - thanks for pointing me there Rich.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags