• Resolved Slamer51

    (@slamer51)


    Hi everybody,

    I wonder how to modify this code to link my header image to another website.

    <h1 class=”site-title”>” rel=”home”><?php bloginfo( ‘name’ ); ?></h1>

    I tried to replace only This : <?php echo esc_url( home_url( ‘/’ ) ); ?>
    with my website https://www.mysite.com inside to quotation but it’s not working.

    Do i need to change sth else ? I m not familiar with the PHP code.

    Can you help out please.

    Thanks

Viewing 14 replies - 1 through 14 (of 14 total)
  • It’s hard to tell because it looks like you have only shared a bit of the code, but you should be able to replace the whole line:
    <?php echo esc_url( home_url( '/' ) ); ?>

    with the link instead.

    Thread Starter Slamer51

    (@slamer51)

    `Thanks for your answer.

    Here it’s the code : part of it gets deleted automatically …This is strange.

    <h1 class=”site-title”><a href=”<?php echo esc_url( home_url( ‘/’ ) ); ?>” rel=”home”><?php bloginfo( ‘name’ ); ?></a></h1>

    Replacing this <?php echo esc_url( home_url( ‘/’ ) ); ?> with https://www.mysite.com is not working.

    do not know how to ? I think this is version 4.3.1 a bit different from the usual code we have in Header.php.

    What you think ?

    Thanks.

    This should work:

    <h1 class="site-title"><a href="https://yoursite.com" rel="home"><?php bloginfo( 'name' ); ?></a></h1>

    Which theme are you using?

    Thread Starter Slamer51

    (@slamer51)

    Thanks

    Well. IT’s still not working !!

    Maybe it’s related to the theme : apostrophe

    Thread Starter Slamer51

    (@slamer51)

    I think it’s a limitation i guess unless I missing something in
    version 4.3.1 ?

    Can you post a link to a page that shows the issue? Also, can you post the contents of header.php to Pastebin and post the link here?

    Thread Starter Slamer51

    (@slamer51)

    Thanks Stephen.

    Here is the link : https://blog.pbicadcam.com/wordpress/&#8230; As i said i need to link the header image to another website.

    https://blog.pbicadcam.com/wordpress/

    As for the code :

    —————————————–

    <?php
            /**
     * @package Apostrophe
     *
     * The Header for our theme.
     *
     * Displays all of the <head> section and everything up till <div id="content">
     */
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
            <head>
                    <meta charset="<?php bloginfo( 'charset' ); ?>">
                    <meta name="viewport" content="width=device-width, initial-scale=1">
                    <link rel="profile" href="https://gmpg.org/xfn/11">
                    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
            <?php wp_head(); ?>
            </head>
    
            <body <?php body_class(); ?>>
                    <div id="page" class="hfeed site">
    
                            <header id="masthead" class="site-header" role="banner">
                                    <div class="site-branding">
                                            <?php
                                            if ( function_exists( 'jetpack_the_site_logo' ) ) :
                                                    jetpack_the_site_logo();
                                            endif;
                                            ?>
    
                                            <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
                                            <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
    
                                    </div>
    
                                    <nav id="site-navigation" class="main-navigation" role="navigation">
                                            <a class="menu-toggle"><?php esc_html_e( 'Menu', 'apostrophe' ); ?></a>
                                            <a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'apostrophe' ); ?></a>
    
                                            <?php wp_nav_menu( array(
                                                    'theme_location' => 'primary',
                                                    'menu_class'     => 'apostrophe-navigation',
                                            ) ); ?>
    
                                            <?php wp_nav_menu( array(
                                                    'theme_location' => 'social',
                                                    'menu_class'     => 'apostrophe-social',
                                                    'link_before'    => '<span>',
                                                    'link_after'     => '</span>',
                                                    'fallback_cb'    => '',
                                                    'depth'          => 1,
                                            ) ); ?>
    
                                    </nav><!-- #site-navigation -->
                            </header><!-- #masthead -->
    
                            <div id="content" class="site-content">

    —————–

    Under Dashboard > Appearance > Customize > Site Title, Tagline, and Logo, what do you have set for “Site Title”? In the same place, do you have “Display Header Text” checked or unchecked? The way your theme is programmed, if you have nothing set for “Site Title” or you’ve unchecked “Display Header Text”, the appropriate <a> tag is generated, but there’s nothing you can actually click on. If that’s the case, you might have to use something like this instead:

    <header id="masthead" class="site-header" role="banner">
      <a href="link/to/your/site">
        <div class="site-branding">
          <?php
          if ( function_exists( 'jetpack_the_site_logo' ) ) :
            jetpack_the_site_logo();
          endif;
          ?>
          <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
          <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
        </div>
      </a>
    
      <nav id="site-navigation" class="main-navigation" role="navigation">

    This way, the entire header area is clickable and leads to the appropriate place.

    Thread Starter Slamer51

    (@slamer51)

    Thanks again.

    Your code is working fine.

    Let me explain : I set nothing for Site title, tagline and Logo.
    Also, the Display header Text is unchecked.

    I did only add the header image and tried to link it via Header.php.

    Quick question : the setting Site title and tagline and logo still the same ? or DO i need to write back the previous code to use them ?

    Thanks

    Thread Starter Slamer51

    (@slamer51)

    ALso,

    DO you know how to add widgets ? for example : upcoming events, Adress & info.
    The last free wordpress version i used had these guys.

    It seems like Apostrophe has only some widgets.

    Thanks

    I did only add the header image and tried to link it via Header.php.

    Did you add the header image by going to Dashboard > Appearance > Customize > Header Image? By default, adding the header image that way won’t automatically set a hyperlink anywhere. But if you used the code I suggested in your child theme’s header.php, the entire header area will become a hyperlink that you can click.

    DO you know how to add widgets ? for example : upcoming events, Adress & info.
    The last free wordpress version i used had these guys.

    Which theme were you using before? Themes can include their own customized widgets, which will be available as long as you’re using that theme. If you switch themes, those widgets will be gone.

    Thread Starter Slamer51

    (@slamer51)

    Thanks again.

    I had free version Apostrophe which had strangely more widgets.

    When i switched to this version, some widgets disappeared !

    But there might be a way to incorporate two more widgets via the code ? can we ?

    Where did you obtain this copy of Apostrophe that had more widgets?

    Thread Starter Slamer51

    (@slamer51)

    Hi stephen,

    Thanks.
    It’s been 1 week ! sorry for this late reply.
    I remember the first time, i register in wordpress and download the free version of Apostrophe to start creating the blog. It doesn’t have Editor under appearance.

    BUt it has more widgets for sure such as : Contat&infos, events,…

    SO i need to figure out a way how to add more widgets or just modify the php code so i can plug pictures on the right.

    1. Do you know how i can do that ? i believe i need to change something in the code right (style.css or other ?)

    2. ALso, i need to delete the counter displayed on the images of articles ?

    Please take a look on : https://blog.pbicadcam.com/wordpress/

    Have a good one.
    Thanks

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘link the header to another website (? php echo )’ is closed to new replies.