1

I have a WordPress website where I have no logo to use and I need to display text instead.

In my custom theme I've added support for a custom logo, but I have no idea of how to display custom text instead of a logo. Is there any function to do this?

Here is the header code I'm using:

  <nav class="navbar fixed-top shadow-lg" id="bs-nav">
    <div class="container-fluid" style="z-index:4;">

      <div class="navbar-header">
        <a class="navbar-brand" href="<?php bloginfo('url'); ?>">
<!-- Here i need to show the text -->
        <?php $logo = wp_get_attachment_image_src( get_theme_mod('custom_logo'), 'full' ); ?>
          <img src="<?php echo $logo[0]; ?>" id="" width="80" height="80">
        </a>
      </div>

      <div class="row">
        <div class="col-sm-12 col-md-12 col-lg-12 float-right">
          <button class="hamburger hamburger--spin" type="button" data-toggle="collapse" data-target="#navbar-content" aria-controls="navbar-content" aria-expand="false" aria-label="<?php _e('Toggle Navigation'); ?>">
            <span class="hamburger-box">
            <span class="hamburger-inner"></span>
            </span>
          </button>
        </div>
      </div>
    </div>

      <div class="collapse navbar-collapse" id="navbar-content">
        <div class="container">
          <div class="row">
            <div class="col-sm-12 col-md-12 col-lg-12">
              <?php
                wp_nav_menu( array(
                    'theme_location' => 'header-menu',
                    'menu'           => 'Menu',
                    'container'      => false,
                    'depth'          => 2,
                    'menu_class'     => 'navbar-nav ml-auto',
                    'walker'         => new Bootstrap_NavWalker(),
                    'fallback_cb'    => 'Bootstrap_NavWalker::fallback',
                ) );
              ?>
            </div>
          </div>
        </div>
      </div>
  </nav>
0

To display the text which you input from Appearance > Customize > Site Identity you can use this code:

<h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel='home'><?php bloginfo( 'name' ); ?></a></h1>

Otherwise, tell us from where that text should be coming from.

You may also try the following:

Open functions.php of your theme and add this:

add_theme_support( 'custom-logo', array(
    'height'      => 100,
    'width'       => 400,
    'flex-height' => true,
    'flex-width'  => true,
    'header-text' => array( 'site-title', 'site-description' ),
) );

Then add the following code wherever you want your logo to appear:

<?php 
   $custom_logo_id = get_theme_mod( 'custom_logo' );
   $image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
      ?>
<img src="<?php echo $image[0]; ?>" alt="">

Then add your logo text inside of Appearance > Customize > Site Identity as shown here: enter image description here

| improve this answer | |
  • I will try with the first code solution you've posted. I already have the possibility to add a custom logo, so the text that is used for the site name will fit my needs. Thank you – sialfa Dec 12 '19 at 19:37
  • You are welcome. If the solution helps you please upvote the solution. – MistaPrime Dec 12 '19 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.