Logo Alternative text

Hi, I would like to be able to insert a shortcode that will generate the alternative text for the site logo, have tried inserting it in footer builder field for logo alt text but it just displays the shortcode text as the alt [show_post_categories show=”title”], alternatively by adding in PHP (in the relevant file?) along the lines of alt="<?php echo the_title(); ?> Keyword"

Thank you.

Hello There,

Thanks for writing in! Regretfully the image element’s alt text only accepts a plain text. It does not allow a shortcode or a php code. This element is hard coded in the theme thus no alternative so far. We can add this as a feature request so it can be taken into consideration for future development.

Thank you for your understanding.

1 Like

@RueNel

Thanks for the reply, I understand what you’ve said, I’d like to know which PHP file I need to edit to achieve my desired results, IE. the file that has the logo code in it?

I have implemented exactly the same in other themes by adding into the respective PHP file (logo.php for example in one other theme)…

Here is an example of how I implemented it in another themes code, “Startit” WordPress theme:

<?php do_action('qode_startit_before_site_logo'); ?>

<div class="qodef-logo-wrapper">
    <a href="<?php echo esc_url(home_url('/')); ?>" <?php qode_startit_inline_style($logo_styles); ?>>
        <img class="qodef-normal-logo" src="<?php echo esc_url($logo_image); ?>" alt="<?php echo wp_title(); ?>"/>
        <?php if(!empty($logo_image_dark)){ ?><img class="qodef-dark-logo" src="<?php echo esc_url($logo_image_dark); ?>" alt="<?php echo the_title(); ?> Contractors"/><?php } ?>
        <?php if(!empty($logo_image_light)){ ?><img class="qodef-light-logo" src="<?php echo esc_url($logo_image_light); ?>" alt="<?php echo the_title(); ?> North West UK"/><?php } ?>
    </a>
</div>

<?php do_action('qode_startit_after_site_logo'); ?>

Can you let me know the Pro, using Ethos, file where I can do similar in please?

Also if possible the altered code I will need to change to make the same effect as in referenced Startit theme code above, I’m not a professional coder, so any help would be much appreciated!

In the above example obviously I’ve simply added alt="<?php echo the_title(); ?> North West UK"/> into the logo display code.

Really hope yourself or someone else can please help :smiley:

Many thanks.

Hey There,

If you are using the default navbar, it will utilize the _brand.php file. If you want to override it, assuming you have your child theme active and ready, please follow the following steps below:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file

<?php

// =============================================================================
// VIEWS/GLOBAL/_BRAND.PHP
// -----------------------------------------------------------------------------
// Outputs the brand.
// =============================================================================

$site_name        = get_bloginfo( 'name' );
$site_description = get_bloginfo( 'description' );
$logo             = x_make_protocol_relative( x_get_option( 'x_logo' ) );
$site_logo        = '<img src="' . $logo . '" alt="' . $site_description . '">';

?>

<?php echo '<h1 class="visually-hidden">' . $site_name . '</h1>'; ?>

<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo the_title; ?>">
  <?php echo ( $logo == '' ) ? $site_name : $site_logo; ?>
</a>

Please make sure that you have made your changes.

3] Save the file named as _brand.php
4] Upload this file to your server in the child theme’s folder wp-content/themes/pro-child/framework/legacy/cranium/headers/views/global/

You will have to created the folder path since it does not exist in your child theme. And please understand that this will only work for the default Pro navbar. If you have created a custom header, this will not work because custom header uses the built in image element which may not be overridden.

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.