WordPress.org

Ready to get started?Download WordPress

Forums

Simple Links
[resolved] Wrap link in header tags? (4 posts)

  1. ResaMichelle
    Member
    Posted 8 months ago #

    Is it possible to wrap the link in header tags?

    Currently, the layout is:

    <a href="link">
    <img src="image" />
    <br>"Link Text"
    </a>
    "—"
    <span class="link description">
    "Link description"
    </span>

    I'd like it to be:

    <a href="link">
    <img src="image" />
    <h3>"Link Text"</h3>
    </a>
    <span class="link description">
    "Link description"
    </span>

    So basically, I want to remove the link break, wrap the link text itself in header tags, and remove the separator between the link and description.

    How would I go about this?

    http://wordpress.org/plugins/simple-links/

  2. Mat Lipe
    Member
    Plugin Author

    Posted 8 months ago #

    Hi ResaMichelle,

    You may achieve this by tapping into the simple_links_link_output filter like so.

    add_filter( 'simple_links_link_output', 'adjust_simple_links_output',99, 6 );
    function adjust_simple_links_output( $output, $data, $link, $image, $args, $obj ){
          $obj->args['remove_line_break'] = true;
          $image = $obj->getImage();
          $output = sprintf('<a href="%s" target="%s" title="%s" %s>%s<h3>%s</h3></a>',
                                        $obj->getData('web_address'),
                                        $obj->getData('target'),
                                        strip_tags( $obj->getData('description') ),
                                        empty( $obj->meta_data['link_target_nofollow'][0] ) ? '': 'rel="nofollow"',
                                        $image,
                                        $link->post_title
          );
          return $output;
    }

    Hope this helps!

  3. ResaMichelle
    Member
    Posted 8 months ago #

    Thanks, this is perfect!

  4. Mat Lipe
    Member
    Plugin Author

    Posted 8 months ago #

    You are welcome!

Reply

You must log in to post.

About this Plugin

About this Topic