Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add Title and Alt Text to Soliloquy Slider
Tagged: soliloquy, Soliloquy Slider
- This topic has 4 replies, 3 voices, and was last updated 8 years, 5 months ago by april.
-
AuthorPosts
-
August 9, 2016 at 9:37 pm #191018aprilParticipant
Hi Everyone 🙂
I'm trying to add the image Title and Alt Text right above the caption on a Soliloquy Slider. I found a way to add the Title and Alt Text but I'm not sure how to combine the codes below. When I use both codes only the Alt Text appears.
//* Add Title to Soliloquy Slider add_filter( 'soliloquy_output_caption', 'sol_soliloquy_title_before_caption', 10, 5 ); function sol_soliloquy_title_before_caption( $caption, $id, $slide, $data, $i ) { // Check if current slide has a title specified if ( isset( $slide['title'] ) && !empty( $slide['title'] ) ) { $caption = '<h4 class="title">' . $slide['title'] . '</h4>'; $caption .= '<div class="caption">' . $slide['caption'] . '</h4>'; } return $caption; }
//* Add Alt Text to Soliloquy Slider add_filter( 'soliloquy_output_caption', 'sol_soliloquy_alt_before_caption', 10, 5 ); function sol_soliloquy_alt_before_caption( $caption, $id, $slide, $data, $i ) { // Check if current slide has a title specified if ( isset( $slide['alt'] ) && !empty( $slide['alt'] ) ) { $caption = '<h4 class="alt">' . $slide['alt'] . '</h4>'; $caption .= '<div class="caption">' . $slide['caption'] . '</h4>'; } return $caption; }
Thank you for any help!
August 10, 2016 at 8:58 am #191057nciskeMemberYour second code snippet replaces the caption variable with the alt text. If you want to add to it instead, you need to concatenate
.=
vs. replace=
.//* Add Alt Text to Soliloquy Slider add_filter( 'soliloquy_output_caption', 'sol_soliloquy_alt_before_caption', 10, 5 ); function sol_soliloquy_alt_before_caption( $caption, $id, $slide, $data, $i ) { // Check if current slide has a title specified if ( isset( $slide['alt'] ) && !empty( $slide['alt'] ) ) { $caption .= '<h4 class="alt">' . $slide['alt'] . '</h4>'; $caption .= '<div class="caption">' . $slide['caption'] . '</h4>'; } return $caption; }
Nick Ciske | https://luminfire.com/ | @nciske
Did I help you? Say thanks: http://bit.ly/1lahwy0August 10, 2016 at 9:00 am #191058nciskeMemberOr, as one snippet: tweak the markup as needed for your site.
//* Add Title & Alt to Soliloquy Slider add_filter( 'soliloquy_output_caption', 'sol_soliloquy_title_before_caption', 10, 5 ); function sol_soliloquy_title_before_caption( $caption, $id, $slide, $data, $i ) { // Check if current slide has a title specified if ( isset( $slide['title'] ) && !empty( $slide['title'] ) ) { $caption = '<h4 class="title">' . $slide['title'] . '</h4>'; $caption .= '<h4 class="alt">' . $slide['alt'] . '</h4>'; $caption .= '<div class="caption">' . $slide['caption'] . '</h4>'; } return $caption; }
Nick Ciske | https://luminfire.com/ | @nciske
Did I help you? Say thanks: http://bit.ly/1lahwy0August 10, 2016 at 9:13 am #191064Victor FontModeratorYour Alt text code is overriding the title code because your calling the two functions with the same priority. Try this:
//* Add Title to Soliloquy Slider add_filter( 'soliloquy_output_caption', 'sol_soliloquy_title_before_caption', 10, 5 ); function sol_soliloquy_title_before_caption( $caption, $id, $slide, $data, $i ) { // Check if current slide has a title specified if ( isset( $slide['title'] ) && !empty( $slide['title'] ) ) { $caption = '<h4 class="title">' . $slide['title'] . '</h4>' . PHP_EOL; } // Check if current slide has a alt specified if ( isset( $slide['alt'] ) && !empty( $slide['alt'] ) ) { $caption = '<h4 class="alt">' . $slide['alt'] . '</h4>' . PHP_EOL; } $caption .= '<div class="caption">' . $slide['caption'] . '</h4>' . PHP_EOL; return $caption; }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?August 10, 2016 at 9:27 am #191065aprilParticipantThank you so much Nick and Victor!
Nick, I was so close. Before I got your message I also created the second code you gave me but didn't use the
.=
so it didnt work. Adding
.
worked perfectly, thank you! -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.