WordPress footer alternative

WordPress: Customize Footer

Übersetzung verfügbar: Deutsch Deutsch

I agree, it’s wunderful that WordPress exists. However, two WordPress links, one in the footer, the next one just 200 pixels away, in the Meta widget, that’s one too much.

OK, let’s assume we are fine with just one link, then we could get rid of the one in the footer, right? As a side effect this would free up some precious space for something useful, such as date and time of the most recent post update!

Nothing easier than that:

That’s the moment to make use of the child theme that we’ve already created.   

(Once again the examples refer to the „Twenty Fifteen“ theme, but it should be applicable to other themes without any major issues.)

  1. Connect to your site via FTP and navigate to the …/wp-content/themes/twentyfifteen-child/ folder.
  2. Open the functions.php file with a suited text editor and paste the following code into it (inside of the php tags):

    // String with title & date of the latest updated post (e.g. for the footer)
    function mostrecent_post_update($d = '') {
    	$recent = new WP_Query("showposts=1&orderby=modified&post_status=publish");
    	if ( $recent->have_posts() ) {
    		while ( $recent->have_posts() ) {
    			$mostrecent_title = get_the_title();
    			$mostrecent_date = get_the_modified_date($d);
    		echo 'Recently updated: <em>' . $mostrecent_title . '</em>, ' . $mostrecent_date;
    		echo ':-(';

    Make sure that the pasted block is positioned between <?php and ?>.

  3. Save and close the file.
  4. Now go to the folder of the main theme; in our example …/wp-content/themes/twentyfifteen/.
  5. Pick the footer.php file and copy it to the child theme’s folder (twentyfifteen-child).
  6. Now we open the copied file …/twentyfifteen-child/footer.php in the text editor. Let’s have a look at line 23: there’s a dummy function do_action( 'twentyfifteen_credits' );.
    • Replace the function in the parentheses with our new function:
      do_action( mostrecent_post_update('') )
    • Comment out the WordPress link <a href= … </a> in line 25.

    The whole thing should now look like this:

     * The template for displaying the footer
     * Contains the closing of the "site-content" div and all content after.
     * @package WordPress
     * @subpackage Twenty_Fifteen
     * @since Twenty Fifteen 1.0
    	</div><!-- .site-content -->
    	<footer id="colophon" class="site-footer" role="contentinfo">
    		<div class="site-info">
    				 * Fires before the Twenty Fifteen footer text for footer customization.
    				 * @since Twenty Fifteen 1.0
    				do_action( mostrecent_post_update('') );
    			<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentyfifteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfifteen' ), 'WordPress' ); ?></a>
    		</div><!-- .site-info -->
    	</footer><!-- .site-footer -->
    </div><!-- .site -->
    <?php wp_footer(); ?>

If we’ve done everything right, the footer now should display the title and the date of the latest modified post: wp-twfi-mod-footer

Sources, Credits, More Info