WordPress

What Changed in WordPress Theme Development Since WordPress 4.1

Since WordPress is always evolving, there is also always something new to learn for WordPress theme developers. New features and optimizations are added with new WordPress versions and since the recent update to WordPress 4.1 included the release of the new 2015 default theme Twenty Fifteen, there are also some new features for WordPress theme developers. To learn more about WordPress themes, the newest default theme is always a helpful resource and you should definitely have a look at the Twenty Fifteen theme files before you get started working on your own theme. Here is an overview about the recent changes since WordPress 4.1.

1. The Title Tag

Since WordPress 4.1 theme authors don’t need to include the title tag into the head section of the header.php anymore. Instead you can use the following new function in your functions.php:

[code]
add_theme_support( ‘title-tag’ );
[/code]

This way WordPress will handle the title tag automatically, which is a big improvement for theme developers. To include the new feature in existing themes without breaking backwards-compatibility you can use the following code in the functions.php:

[code]
if ( ! function_exists( ‘_wp_render_title_tag’ ) ) :
    function yourthemeslug_render_title() {
?>
<title><?php wp_title( ‘|’, true, ‘right’ ); ?></title>
<?php
}
add_action( ‘wp_head’, ‘yourthemeslug_render_title’ );
endif;
[/code]

Further Infos:
You can find further information about the new title tag in the WordPress-Codex and in the Title Tags in 4.1 post at Make.WordPress.org.

2. New Archive Title Template Tags

It also got easier to show the archive titles and archive title descriptions since WordPress 4.1 with the following new template tags:

  • get_the_archive_title() and the_archive_title()
  • get_the_archive_description() and the_archive_description()

So you can now just use the following code in your archive.php file to include your archive titles:

[code]
<header class="page-header">
< ?php
the_archive_title( ‘<h1 class="page-title">’, ” );
the_archive_description( ‘<div class="taxonomy-description">’, ‘</div>’ );
?>
</header><!– .page-header –>
[/code]

Visit the Make WordPress-Core Blog to find further information about the archive title tags .

3. New Template Tags for Post Navigations

You can now also handle the navigation between single posts on the single post pages as well as the navigation between your blog pages easier with the following new template tags for post navigations:

  • get_the_post_navigation() and the_post_navigation() for the next and previous navigation between posts on single post pages.
  • get_the_posts_navigation() and the_posts_navigation() for the navigation to previous and next pages of your blog.
  • get_the_posts_pagination() and the_posts_pagination() for a numbered page navigation of your blog pages (which is also used in the new Twenty Fifteen theme). This option is completely new, before you had to use the WordPress plugin WP Page-Navi to get the same result.
How is it used in the Twenty Fifteen theme:

You can see the new numbered blog navigation in action in the index.php file of Twenty Fifteen:

[code]
// Previous/next page navigation.
the_posts_pagination( array(
‘prev_text’ => __( ‘Previous page’, ‘twentyfifteen’ ),
‘next_text’ => __( ‘Next page’, ‘twentyfifteen’ ),
‘before_page_number’ => ‘<span class="meta-nav screen-reader-text">’ . __( ‘Page’, ‘twentyfifteen’ ) . ‘ </span>’,
) );
[/code]

To navigate between new next and previous post the new default theme uses the following code in it’s single.php file:

[code]
// Previous/next post navigation.
the_post_navigation( array(
‘next_text’ => ‘<span class="meta-nav" aria-hidden="true">’ . __( ‘Next’, ‘twentyfifteen’ ) . ‘</span> ‘ .
‘<span class="screen-reader-text">’ . __( ‘Next post:’, ‘twentyfifteen’ ) . ‘</span> ‘ .
‘<span class="post-title">%title</span>’,
‘prev_text’ => ‘<span class="meta-nav" aria-hidden="true">’ . __( ‘Previous’, ‘twentyfifteen’ ) . ‘</span> ‘ .
‘<span class="screen-reader-text">’ . __( ‘Previous post:’, ‘twentyfifteen’ ) . ‘</span> ‘ .
‘<span class="post-title">%title</span>’,
) );
[/code]

4. No extra Custom Header and Custom Background Pages in the Admin

Instead of having an extra “Custom Header” and “Custom Background” page in your admin area the links are now redirected directly to the Customizer.

For WordPress theme developer this is a lot easier, since you don’t have to style your theme’s default title on the Custom Header admin page any longer. But you still need to include the custom-header.php file in your theme, you can just delete the parts handling the admin area.

For WordPress users this is also an improvement, since it is easier and more intuitiv to have all theme customization options together in one place. And the customizer also offers the nice preview option, so that you can see your changes live.

Your Feedback

Do you know of any further recent changes in WordPress, which effect the theme development? And which recent new features do you like the most? Let me know, I’m looking forward to your feedback and further tips.

Leave a Reply

Your email address will not be published. Required fields are marked *