specify alt and title for [client] shortcode

Home Forums All Other Themes specify alt and title for [client] shortcode

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #102362
    wilfried
    Participant
    • Topics: 40
    • Replies: 98
    • Total: 138
    Member since: December 7, 2017

    Hi,

    site: http://actisan.be/ wp /
    theme: Gardener

    I like very much your shortcode for [client] like this: [client url=”#” image=”image url”]

    But is it also possible to specify the alt=”alt” and title=”title” for the image?
    Is this something I can try to add myself? But where should I search?

    #102366
    wilfried
    Participant
    • Topics: 40
    • Replies: 98
    • Total: 138
    Member since: December 7, 2017

    I found it myself. In case someone else need this. There are 2 options, first is fast, second is preferable:

    1. you an edit the code in wp-content/themes/skt-gardening/sktframe/core-functions.php like this:
    function clientbox($atts){
    extract( shortcode_atts(array(
    ‘url’ => ‘url’,
    ‘image’ => ‘image’,
    ‘alt’ => ‘alt’
    ), $atts));

    return ‘
    <div class=”clientbox”>
    '.$alt.'`

    2. You can make a plugin for it (looks safer) where you can add other things as well. Create a folder eg: ‘my-thing’, put there a file in and name it ‘my-thing.php’, then put the following in that file:

    <?php
    /*
      Plugin Name: My Thing
      Description: some description
      Author: your name
      Version: 1.0
      Author URI: http://your site
    */
    
    // Shortcode MyClient
    /*[myclient url="#" image="image" alt="alt"]*/
    function myclientbox($atts){
    		extract( shortcode_atts(array(
    			'url' => 'url',
    			'image' => 'image',
    			'alt' => 'alt'
    		), $atts));
    		
    		return '
                    <div class="clientbox">
                        <a href="'.$url.'" target="_blank"><img src="'.$image.'" alt="'.$alt.'" title="'.$alt.'" /></a>
                    </div>
    		';
    }
    add_shortcode('myclient','myclientbox');

    Then use the shortcode [myclient] instead of [client].

    Of course if someone knows other / better options the please share 😉

    #102371
    wilfried
    Participant
    • Topics: 40
    • Replies: 98
    • Total: 138
    Member since: December 7, 2017

    I messed up the option 1 in my reply. In fact it is just change the line with ‘alt’ in it and after the return you have to add ‘alt’ and ‘title’ as in the second option.

    #102432
    SKT Themes
    Keymaster
    • Topics: 8
    • Replies: 6705
    • Total: 6713
    Member since: June 12, 2013

    Custom requirement of modifying existing shortcode. Connect with us via email: @sktthemes.com">support@sktthemes.com

    Mention this forum URL there.

    Regards,
    Shri

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.