Whats New In WordPress 4.7
WordPress 4.7 is in beta 2 and there are some nice new features being added to the new version. Hopefully they will be fully released soon, but here's some of the features you can look forward to seeing in 4.7.
As with every new WordPress release there is a new WordPress 4.7 theme Twenty Seventeen.
- A better flow for using a static page as your front page.
- Visible edit icons in the Customizer, replacing the current hidden shift+click method.
- Expanding custom header images to include video (think: atmospheric video headers!).
- Dummy content for live previews.
To look at some of the new features inside WordPress it's always a good idea to look over this theme at the new features so you can explore.
Find out more: Twenty Seventeen
One of the best new features is the Theme setup flow, allowing you to list a flow of jobs to perform in the customiser to improve the theme setup.
REST API Endpoints
- Posts: Read and write access to all post data, for all types of post-based data, including pages and media.
- Comments: Read and write access to all comment data. This includes pingbacks and trackbacks.
- Terms: Read and write access to all term data.
- Users: Read and write access to all user data. This includes public access to some data for post authors.
- Meta: Read and write access to metadata for posts, comments, terms, and users, on an opt-in basis from plugins.
If you want to keep up to date with the RESTful API changes you can follow the Github repo
get_blog_details() used to be used to get information stored in the wp_blogs table, in 4.7 this has been replaced by the get_site() function as it will return the WP_Site object. You can still use get_blog_details for now but in WordPress 4.8 it will most likely be deprecated.
Inline with the removal for
get_blog_details() the filter
blog_details has also been removed to be replaced with
wp_get_network() function has been deprecated and advised to use
get_network() instead to return the WP_Network object to get all the information for your multisite network.
Post Type Labels
When you need to create a new post type in WordPress you'll use the function
register_post_type(), within this function you pass in the labels you want to call the post type there have been two new post type labels added to the function.
view_items- This label is used in the toolbar on the edit screen
attributes- This label is used in the post attributes meta box
Post Type Templates
WordPress has supported custom page templates for years but this has always been limited to Pages meaning if you want something different for a post you'll need to use something like the
template_include to change the theme files used.
You can see an example of overriding post theme files here: How To Use Page Templates In A Plugin
In 4.7 you now have the ability to define what post type a template can be used on by using the file comment
Template Post Type.
To create a custom page template you need to add a comment to the top of the file
/** * Template Name: Product Offer Page */
For this to be changes on a post you'll need to use the comment Template Post Type.
/** * Template Name: Product Offer Page * Template Post Type: post, page, product */
Now we can use this template on the post types post, page and product. Just like the Page functionality you'll have a template select dropdown on the page attributes section in the admin area to select the template file to use for this post.
In WordPress 4.6 support was headed for resource hints allowing you to define dns-prefetch, preconnect, prefetch, and prerender this tells the browser how to handle resources to help improve the performance of loading your site.
Using the filter
wp_resource_hints you'll be able to change more for the attributes used in the resource hints.
Array Utility Functions
There have been two new utility function functions added to make it easier to work with arrays.
wp_list_sort() makes it easy to sort a list of object by an attribute on that object. For example if you have a list of WP_Post objects then you can now easily sort these by using.
$sorted_posts = wp_list_sort( $posts, 'post_date', 'DESC' )
Or you can pass in multiple options for sorting by using an array of options.
$sorted_posts = wp_list_sort( $posts, array( 'post_date' => 'DESC', 'post_title' => 'ASC', ) )
WP_List_Util is now your central point for managing lists utilities.
User Admin Languages
Version 4.7 allows you to select a language for a specific user, these can be changed on the Your Profile for every user.
This allows the user to select their own locale which will change the language for that one user in the admin area. Before when you set a locale for the WordPress site all users will need to use this language now each user can set their language.
Fastest WordPress Hosting With WPEngine
Stunning speed, powerful security, and best-in-class customer service. At WP Engine.
Join the weekly newsletter
Sign up for our newsletter. You'll be updated on new tutorials as they come available.
Subscribe today and get a 50% discount code to Paulund