• Hi, I need help with my footer.php.

    1. I want to display the copyright year with the name of my company with a link to my external site. I have gotten pretty far but the link is pointing to the current site and returning a page not found error. I’m so close! I need a fresh pair of eyes on this. I’m using a Sela child

    2. I’d like to increase the spacing between the social icons in the footer. The site is 9gallons.pub.

    Thank you in advance

    </div><!-- #content -->
    
    	<?php get_sidebar( 'footer' ); ?>
    
    	<footer id="colophon" class="site-footer">
    		<?php if ( has_nav_menu ( 'social' ) ) : ?>
    			<?php wp_nav_menu( array( 'theme_location' => 'social', 'depth' => 1, 'link_before' => '<span class="screen-reader-text">', 'link_after' => '</span>', 'container_class' => 'social-links', ) ); ?>
    		<?php endif; ?>
    
    		<div class="site-info"  role="contentinfo">
    			<?php
    $year = date('Y');
    if ($year != 2017){
    echo '© 2017 – '.$year.' <a href=“http://www.musely-wd.com/” target=“blank”>Musely</a>';
    } else {
    echo '© 2017 <a href=“http://www.musely-wd.com/” target=“blank”>Musely</a>';
    }
    ?>
    		</div><!-- .site-info -->
    	</footer><!-- #colophon -->
    </div><!-- #page -->
    
    <?php wp_footer(); ?>
    
    </body>
    </html>
    
    • This topic was modified 7 years, 2 months ago by muselywd.
Viewing 5 replies - 1 through 5 (of 5 total)
  • You need to stop using hardcoded urls. Try:

    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>

    And please do not use target=“blank" on links as it leaves some users stranded on the new page without any effective way to navigate back to the original page.

    Thread Starter muselywd

    (@muselywd)

    This isn’t working for me

    • This reply was modified 7 years, 2 months ago by muselywd.
    • This reply was modified 7 years, 2 months ago by muselywd.
    Thread Starter muselywd

    (@muselywd)

    It now looks like this, no links but the code works. The code you gave me vanished my footer completely.

    </div><!-- #content -->
    
    	<?php get_sidebar( 'footer' ); ?>
    
    	<footer id="colophon" class="site-footer">
    		<?php if ( has_nav_menu ( 'social' ) ) : ?>
    			<?php wp_nav_menu( array( 'theme_location' => 'social', 'depth' => 1, 'link_before' => '<span class="screen-reader-text">', 'link_after' => '</span>', 'container_class' => 'social-links', ) ); ?>
    		<?php endif; ?>
    
    		<div class="site-info"  role="contentinfo">
    			<?php
    $year = date('Y');
    if ($year != 2017){
    echo '© 2017 – '.$year.' Musely-WD.com';
    } else {
    echo '© 2017 Musely-WD.com';
    }
    ?>
    		</div><!-- .site-info -->
    	</footer><!-- #colophon -->
    </div><!-- #page -->
    
    <?php wp_footer(); ?>
    
    </body>
    </html>
    Moderator bcworkz

    (@bcworkz)

    You can space the icons by changing or overriding the existing margin style. Because your CSS is cached, I cannot tell you where to change this. In any case, if this is not a child theme, you should create one to override the main theme rules. Your theme may have a place for custom CSS, if it does, use it instead of making a child theme.

    .social-links ul li {
      margin: 0 5px;
    }

    I don’t think esmi realized the link is external to the site. While it’s possible (and kinda cool) to add a custom setting field in which to specify the copyright holder’s site, hardcoding external links is a pretty common practice. I’d go ahead and put the hardcoded links back in unless you want to add a settings field. She is right about the new window bit though, don’t do that!

    You could have the if()else logic only manage the copyright and year part of the output, then output your site and link outside of the if()else structure so it only needs to occur once. Always strive to never replicate data! In fact, the “© 2017” only needs to occur once, the decision is only whether to output “– $year” or not.

    Thread Starter muselywd

    (@muselywd)

    Sorted! The code was a bit rubbish and I decided to lose the “-$year” output.
    The social media icons have spaced perfectly also. Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Copyright Link in footer.php’ is closed to new replies.