Support » Plugin: Simple Links » Add and display custom fields like %class%, %itemprop%

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mat Lipe


    Hi iox,

    Are you trying to used the custom fields as link attributes such as ‘class=”mail-link”‘? Or are you trying to display the custom fields below the links?

    link attributes


    Plugin Author Mat Lipe


    Hi iox,

    Currently there is no way to do this through the admin, however it is on the list for possibilities when version 2.0 is released.

    You may accomplish this adding the following code to your themes functions.php file.

    add_filter('simple_links_shortcode_link_output', 'add_simple_link_attribute', 1, 4 );
    add_filter('simple_links_widget_link_output', 'add_simple_link_attribute', 1, 4);
    function add_simple_link_attribute($output, $meta, $link, $image){
        $atts = ' ';
        foreach( (array)json_decode($meta['link_additional_value'][0]) as $k => $v){
            $atts .= sanitize_title($k).'="'.sanitize_text_field($v).'" ';
        $output = sprintf('<a href="%s" target="%s" title="%s" %s%s>%s%s</a>',
                        empty( $meta['link_target_nofollow'][0] ) ? '': 'rel="nofollow"',
        return $output;

    This will adjusted both the widget and the shortcode. All additional fields will be added to the links as attributes.

    Hope this helps.

    I think it would be a good option for semantics and microdata.

    <a href="mailto:#"
    <a href="tel:911"

    Thanks, Mat!


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add and display custom fields like %class%, %itemprop%’ is closed to new replies.