Home › Forums › All Other Themes › specify alt and title for [client] shortcode
- This topic has 3 replies, 2 voices, and was last updated 6 years, 5 months ago by Sonl Sinha.
-
AuthorPosts
-
June 8, 2018 at 11:50 am #102362
Hi,
site: http://actisan.be/ wp /
theme: GardenerI 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?June 8, 2018 at 1:04 pm #102366I 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”>
`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 😉
June 8, 2018 at 1:15 pm #102371I 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.
June 11, 2018 at 10:42 am #102432Custom requirement of modifying existing shortcode. Connect with us via email: [email protected]
Mention this forum URL there.
Regards,
Shri -
AuthorPosts
- You must be logged in to reply to this topic.