Whats New In WordPress 4.4
WordPress version 4.4 is currently on beta 4 stage with a release to be expected in the 2nd week of December around the 8th. With design and development starting from the end of August let's have a look at some of the new features included in WordPress 4.4.
This new feature allows other people to embed your content elsewhere on their site. Using a number of new filters you will be able to customise how your site looks and behaviours when it has been embedded onto someone else's site.
This works by turning your site into a oEmbed provider, allowing any site that supports oEmbed to embed your content on their site.
For developers this means when you create the site you will need to think about how you style the site when it's embedded. Any content that is publicly available will be able to be used in the oEmbed system. Using pretty links your embed content will be displayed in an iframe accessing through the URL of example.com/your-post/embed/.
There are a number of new functions you can use with this new feature
- get_post_embed_url() — Retrieves the URL to embed a specific post in an iframe
- get_post_embed_html() — Retrieves the full embed code for a specific post.
- get_oembed_endpoint_url() — Retrieves the oEmbed endpoint URL for a given permalink, e.g. https://example.com/?oembed=true&url=
. This is used to add the oEmbed discovery links to the HTML for single posts.
- get_oembed_response_data() — Retrieves the oEmbed response data for a given post, according to the oEmbed specification.
If you don't like the sound of people being able to embed your content you can install the following plugin to turn off this feature.
REST API Infrastructure Introduction
The big change in 4.4 is moving the REST API into the core of the WordPress product. Although this feature hasn't been merged in at the moment you can currently get the features by downloading the REST API plugin.
So what does this mean?
This creates a number of RESTful API endpoints to interact with your WordPress site. For the lifetime of WordPress if you want to have an easy to use CMS you will have to display the front-end of the site using the WordPress theme. With the introduction of the WP API means you can use the WordPress database to manage the content and have the front-end of your site in any language/framework you want, simply by interacting with the RESTful API.
As I said this is still in development if you're interested in it's progress then you can watch the repository on Github.
WordPress will now add additional attributes to the img tag when adding images to aid in responsive images in your WordPress theme. At the moment when you add an image to your editor it will automatically add HTML attributes for class to align the image on the left, center or right. The new update will add two new attributes for srcset and size.
Using these attributes will allow the browser to download the correct size images for the viewport.
This comes with a number of new filters allowing you to customise the default sizes by using the filter wp_calculate_image_sizes.
- wp_get_attachment_image_srcset() – Retrieves the value for an image attachment’s srcset attribute.
- wp_calculate_image_srcset() – A helper function to calculate the image sources to include in a srcset attribute.
- wp_get_attachment_image_sizes() – Creates a sizes attribute value for an image.
- wp_calculate_image_sizes() – A helper function to create the sizes attribute for an image.
- wp_make_content_images_responsive() – Filters img elements in post content to add srcset and sizes attributes. For more information about the use of a display filter, read this post.
- wp_image_add_srcset_and_sizes() – Adds srcset and sizes attributes to an existing img element. Used by wp_make_content_images_responsive().
Ever since the release of WordPress 4.1 it has been recommended to use the function.
add_theme_support( 'title-tag' );
To auto generate the title tag in your WordPress theme, this is done by adding the HTML into the wp_head() output.
Originally the wp_title() function was going to be deprecated or removed from the core, but this is not the case anymore and has been kept in the core functionality but is classed as deprecated as a ghost function. This means you can still use the function but it is recommended that you don't, therefore all developers should not use this function moving forward and try to update your previous themes to not use this anymore.
Term Taxonomy Meta
With each release of WordPress the developers are slowly moving to a more OOP structure you can see this with the addition of a new object for handling terms and taxonomies with the object WP_Term.
The biggest improvement to this is the use of term meta, allowing you to add custom field content to a taxonomy object just like you do on posts and pages by using the following functions add_term_meta(), update_term_meta(), delete_term_meta(), and get_term_meta().
Before if you would want to create term meta you would have to create site_option data explained in this tutorial
Now you can do all this by using the WP_Term object, I will update the above tutorial with information on how to achieve the samething using the WP_Term object.
Along with terms, comments has had a small update with the WP_Comment object, allowing you to manage the output of the comments in a more OOP way.
The default comment form has also had a little rearrange with the comment form now appearing first before the name and email fields.
Multisite WP_Network Object
In keeping with the OOP changes there is a new object for multisite being the WP_Network object. This makes it easier to customise the the data used across a network of sites, with the addition of new functions add_network_option(), update_network_option(), get_network_option(), and delete_network_option() are all new functions in 4.4.
Twenty Sixteen Theme
With each release of WordPress they always release a new theme that will demonstrate how to use some of the new features included in the latest release, this is the purpose of the twenty sixteen theme.
When you download the new version of WordPress be sure to read the code inside the theme to see how it uses the new features.
If you want to view the theme now you can see the code on the Github repository.
Single Post Template File
One neat little feature of WordPress 4.4 is the creation of the single post - post name template file included in the theme file hierarchy.
This template file will allow you to have a new design for an individual post, can be a nice feature to use if you have an eCommerce shop and want to display this page differently to the others, or have an offer on something you can make this page different to anything else on your site.
These are some of my favourite features with WordPress 4.4 I'm looking forward seeing what can be created with the RESTful API or what hybrid sites can be created with it. 4.4 is still in testing you can download the beta right now and have a play but I wouldn't recommend using it on a live site until it has been released.
What's your favourite new feature in WordPress 4.4?
Learn how to code with Treehouse
- Learn projects with access to 1000+ videos
- Practice live with our Code Challenge Engine
- Get help in our members-only forums
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