• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add Title and Alt Text to Soliloquy Slider

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add Title and Alt Text to Soliloquy Slider

This topic is: resolved

Tagged: soliloquy, Soliloquy Slider

  • This topic has 4 replies, 3 voices, and was last updated 6 years, 7 months ago by april.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • August 9, 2016 at 9:37 pm #191018
    april
    Participant

    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 #191057
    nciske
    Member

    Your 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/1lahwy0

    August 10, 2016 at 9:00 am #191058
    nciske
    Member

    Or, 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/1lahwy0

    August 10, 2016 at 9:13 am #191064
    Victor Font
    Moderator

    Your 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 #191065
    april
    Participant

    Thank 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!

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble