Reviews are perhaps one of the most powerful blogging tools. Properly designed and filled with solid information, review blogs belong to one of the most profitable categories of resources in the blogosphere in terms of monetization. But every blog should offer a consistent design, including a review section. This post will show you how to create a near-perfect book, movie, or product review block (because the quick review block is the section that readers check first before moving on to the full review).

What we plan to create

How to use custom fields to create review meta boxes

As an example, let’s create a block with a movie review. Take one of my favorite films: The Pursuit of Happyness. The block will display the following information about the movie:

Title: The Pursuit of Happyness

Year: 2006

Directed by: Gabriele Muccino

Screenwriter: Steve Conrad

Cast: Will Smith, Jaden Smith, Thandie Newton

Genre: Biography, Drama

Duration: 117 minutes

Plot: The film is based on the true story of a man named Christopher Gardner. He invested a lot of money and effort into a device called “Bone Density scanner” (something like a portable radiograph). But he could not sell any of the created devices, since they were, although better than all existing technologies, but significantly more expensive. As soon as Gardner realized that he could not sell any of these devices, his wife left him, he lost his house, his credit card and bank account were closed. Left penniless and forced to live on the streets with his son, Gardner despaired of finding a permanent job; he gets a job as a broker on the stock exchange, but before he gets his first salary, he has to go through a trial period of 6 months and during this time manage to sell the remaining scanners he has.

And of course – do not forget about the picture-illustration for the annotation of the film.

Important note: We take all data about the film from the IMDB rating.

Step 1: Preparing a custom meta form to populate it with data

The data will be entered into custom fields, but manually adding such fields to each new review is a pain in the ass. So we’ll create a custom meta box that will hold the data for our custom fields.

First we need to create the add_meta_box() function to create the meta box and write the callback function:

Writing a function to display a block with an overview

Now that we have decided how to set up the output of information, it’s time to study how we will receive information. If you have previously worked with custom fields, then you will not have any particular difficulties. We’re just comparing the input and output of the custom fields.

WordPress has an easy to use function for getting custom field values:

one

$meta_values โ€‹โ€‹= get_post_meta($post_id, $key, $single);

We need to load the values โ€‹โ€‹of the custom fields into the HTML code, so it’s a good idea to take care of what this HTML code will be in advance.

CSS styles

It goes without saying that the review block can be stylistically designed to your liking. If there is no such desire, then you can use our ready-made design style

Create a shortcode to call a function

We know how to set up and how to get informational data… It’s time to learn how we will display our data.

An overview block can be automatically added at the end or at the beginning of your post like this:

function wptuts_review_box_add($content) {

    $review_box = wptuts_review_box();

    // show the box at the end of the post:

    return $content.$review_box;

    // show the box at the beginning of the post:

    // return $review_box.$content;

} add_action(‘the_content’,’wptuts_review_box_add’);

But what do we do if you want to insert a review block in the middle of a post? And here comes the time of my favorite tool – shortcodes.

This step is even easier than the previous one, because all the preliminary work for loading the overview block has already been done. All that’s left to do is call the function using the shortcode:

one

add_shortcode(‘reviewbox’,’wptuts_review_box’);

And this is what you will get as a result if you have done all the previous steps exactly as it was written in this post:

How to use custom fields to create review meta boxes

Completing the work

Review boxes can be used to annotate a wide variety of content, from quick reviews of software and websites to books, TV shows, movies, and more. Even in ordinary blogs, you can use this format for presenting information for fun.

Other helpful articles on the subject:

WordPress Custom Post Types Guide

Custom Post Types: Custom Taxonomies, Filters and Archives in WordPress

If you have more ideas on how you can improve the way forms and blocks of text or graphics work on your site, we invite you to share your experience in the comments on this post.

WordPress Custom Post Types Guide

custom post types, wordpress customization 25

WordPress is built for customization. It was created in such a way that every part of it can be customized. In this guide, we’ll be covering one of the most powerful features of WordPress known as custom post types and how WordPress has risen to the occasion with this awesome feature.

What are Custom Post Types?

Let’s say you want to create a separate section for movie reviews on your blog. Using custom post types, you can create a new post type like Post or Page that contains a different set of data. It will have its own admin menu, separate editing pages, its own taxonomy and other features necessary for full-fledged publications.

Why use custom post types?

Custom post types help you store different post types in different buckets. They separate our regular records from others. Very simple!

An example of creating a Custom Post Type plugin

Here we will create a plugin to display a new post type that will show our movie reviews. Let’s start.