Custom Post Type for Book Reviews

Custom post types are a great way to create more interesting content. Make your book reviews look great with a few simple steps!


If you read a lot, or just some even, and want to share your insights and opinions with others, a great way is to add a custom post type on your website. A custom post type is essentially the exact same thing as the default ‘Post’ in WordPress. Coding or using plugins will enable you to create your very own post type, like the one I created called ‘Books’.

For this post I’ll use the Pods Plugin to set up the custom post types and add templates for displaying on the frontend. The process might be the same or very similar with other plugins. Other than Pods, no additional plugin is needed.

I have previously written about how to set up Pods plugin on WordPress here.

The finished result looks something like this:

I wanted it to look similar to the layout of book stores, with the cover on the left and then clickable links to the author’s archive and to the genres if the visitor would like to see what else is in the same genre.

Book Reviews: The Parts

My goal was to create a post type that would display well on the frontend with custom categories for genres, and another for authors. In this case I didn’t bother setting up tags since I think genres do the trick.

The project will thus consist of 3 custom post- and taxonomies:

  • Book Review, the custom post type
  • Authors, the custom, hierarchical taxonomy for listing the authors
  • Genres, the custom, hierarchical taxonomy for listing the genres
Create the Custom Post Type for the Book Review posts.

Setting up Book Review as custom post type

The main custom post type have 15 custom fields, which are inputs that you can call in different places. For example, one field is called ‘book_title’ and contains the title of the book, similar to ‘book_subtitle’. This enables you to call the different fields in different places, perhaps if you want to display only the main title in the feed and the whole title on the single page, as shown here. The other fields I use are:

  • Title (plain text) – The main title of the book
  • Subtitle (plain text) – The subtitle of the bok
  • Author (plain text) – A plain text field for the author’s name
  • Series (plain text) – The name of the series the book’s a part of, if any
  • Series-no (plain number) – The number of the book in the series
  • Quote (plain text) – A short quote from, or about the book that might peak the reader’s interest
  • Rating (plain number) – My rating, number 1-5
  • Language (plain text) – The language of the book
  • Pages (plain number) – Number of pages in the book
  • Publisher (plain text) – The publisher
  • Published (date) – Date of publish
  • ISBN (plain number) – ISBN number
  • URL (website) – Link to where the reader can purchase or read more about the book
  • Content (WYSIWYG – Visual Editor) – Summary of the book
  • Review (WYSIWYG – Visual Editor) – Review of the book

I’ve chosen to divide the content and review into different fields if I would want to display one or the other anywhere. There’s no real reason other than that and if you prefer, go with just one field for summary+review.

Advanced Options

Under ‘Supports’ I’ve enabled the following:

  • Title
  • Featured image
  • Excerpt
  • Quick edit

I’ve disabled the Gutenberg ‘Editor’ since I’ve had trouble using it together with custom post types and found it better to just add what fields I need in the CPT directly.

I do, however find the Featured image and Excerpt very useful to use in Queries and post lists! Quick edit is always nice to have, too.

Setting up author taxonomy

This is pretty straight forward, I wanted to create the possibility to have a dedicated page for each author, should I want to add a bio, website, profile picture, or whatever else. I thought a category would do the trick, with all the authors as parent-level categories. I could then add the book series as a sub-category for each author to be able to better sort and display the books and series later on as I add more books for each author. For now, though, the author custom taxonomy consist of two custom fields:

  • Bio – A WYSIWYG for creating a nice-looking bio on each author
  • Website – Just a url field to be able to link to the authors website

Setting up genres taxonomy

Just like the author taxonomy, the genre one is very simple and straight forward. It doesn’t even have additional fields, just a flat taxonomy. This is obviously to be able to create branches of genres as I add books, making it easier to find certain books.

Displaying Book Reviews on the Frontend

Now, we’re basically ready to get writing book reivews! However, we still need to display them properly on the frontend.

Create a Front Page Feed

For the purpose of displaying the book review as a feed on the front page, simply do the same as if you where about to create a normal WordPress post feed. I use the full site block editor for this.

Create a ‘Single Book Review’ template with Pods

My goal here was to have a nice looking single post page for the books. I want to highlight the book cover on the left side while listing the important information about the book on the right side. Then below, a summary of the book and below that the actual review. Very simple.

The main problem I ran into was to set up the dynamic links in the meta fields next to the image.

Displaying the name of the author while linking to the author category

Since I don’t do too much coding myself, I had to ask ChatGPT who, after quite a few back and forth came up with a code that does just that!

In this code, WP gets the information about the author and whether the author created any book series that this current book is a part of. It then outputs the information in a link that directs the viewer to the author’s page, if they click it.

Simple and effective!

 <p> <?php $authors = get_the_terms(get_the_ID(), '[author]'); if ($authors && !is_wp_error($authors)) { echo '<span>Author: '; $author_links = array(); foreach ($authors as $author) { // Check if the term is a parent term if ($author->parent == 0) { $author_links[] = '<a href="' . esc_url(get_term_link($author)) . '">' . esc_html($author->name) . '</a>'; } } echo implode(', ', $author_links); echo '</span>'; } ?> <br> <?php $authors = get_the_terms(get_the_ID(), 'author'); if ($authors && !is_wp_error($authors)) { $series_links = array(); foreach ($authors as $author) { // Check if the term is a child term if ($author->parent != 0) { $series_links[] = '<a href="' . esc_url(get_term_link($author)) . '">' . esc_html($author->name) . '</a>'; } } // Check if there are series links to display if (!empty($series_links)) { echo '<span>Series: '; echo implode(', ', $series_links); echo '</span>'; } } ?> </p>

This is pretty much how my book review custom post type works, please do give me a shout if you have further questions or comments!


Comments

Leave a Reply

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

Recent notes

Malicious AI-bots are on a holiday shopping spree

AI bots have entered the holiday! Though not as jolly joy spreaders as one could’ve hoped, but as tools for scammers to exploit the season’s shopping spree.

Read more

AI bots have entered the holiday! Though not as jolly joy spreaders as one could’ve hoped, but as tools for scammers to exploit the season’s shopping spree.

The Problem

During the holiday shopping season, retailers have seen a large increase in fraudulent purchases from bots. This new iteration of bots are able to mimic the average customer, making them more difficult to detect. It allow them to purchase large quantities of high-demand products quickly, perhaps to resell at later times at hiked prices.

They are also able to more effectively identify vulnerabilities in the systems used by the retailers, thus allowing for ransomware, takeover off customer’s accounts, or manipulate prices through discount codes.

Today’s retailers see an average of 560 000 daily such AI-driven attacks.

Solutions

Anyone familiar with the purchasing flow of sites like Amazon know it’s incredibly easy to purchase any product. Once you’ve got your account you’re about 2-3 clicks away from ordering a product – any product.

But the trade-off here is security. Creating additional steps for purchasing online will make the consumer have more opportunities to stop and rethink their choice, which is what retailers, especially online ones, struggle with today. This could somewhat be helped by setting up blocking for malicious domains and IP’s, a practice many companies already adhere to.

A fricitonless approach makes for more opportunity for scammers to exploit and penetrate the process than a process with more security measures set up will.

It’s not an easy trade-off in today’s dopamin-infused world where customers won’t hesitate for a second to swipe along to another retailer!

Read less

2024-11-28 02:01 | 0 comments

Pressing Pause on Streaming: Is Physical Media Making a Comeback?

Are people increasingly turning away from the comfort of streaming services and back towards physical mediums? That’s what some people are experiencing, and I’d be lying if it hadn’t crossed my mind as well.

Read more

Are people increasingly turning away from the comfort of streaming services and back towards physical mediums? That’s what some people are experiencing, and I’d be lying if it hadn’t crossed my mind as well.

Downsides of streaming services

What a lot of people, myself included, have experienced with streaming services is the sudden disappearance of the show I’m currently watching or a movie I plan to watch. This has been a recurring theme in our house where we’re about to put on the Friday movie with the kids and it’s just gone. Of course, there are always others, but if you’ve hyped up 3 kids for a movie, there’s going to be some disappointment.

Another downside, that’s really not quite a downside, is the way we’ve been watching movies in. Before streaming services we decided on a movie for the evening, put the movie on and watched it. Afterwards we normally did other things. Now, the ease of starting another movie after the first one allows for whole evenings spent on the couch in front of the black box. The movie is nowhere near as “important” to the setting anymore.

Recent uptick in physical sales

According to BBC News, there’s been a recent uptick in the sales of physical visual, and more specifically Blu-ray discs. Despite being more expensive than their streamed counterparts they are steadily on the rise.

“If you hold it in your hand, it’s yours”

Personally, I believe a lot of people simply have started getting tired of the endless subscriptions we pay for different services. I myself have been going over my old CD-collection and am looking to possibly purchase a new stereo to rid myself of Spotify. It’s a good service, but I’m generally listening to the same songs and artists over and over, paying the approximate price for an album every month.

If I purchase 12 albums per year, I have exactly 12 albums after one year that I never have to pay for again. I can download the songs to my phone and listen to when I’m not home, at the same time my wife or kids listen to the same album at home.

Buy it once, enjoy it forever.

Will streaming become a thing of the past?

It’s quite unlikely that streaming will go away anytime soon. It’s simply too convenient and comfortable to put on and just leave in the background. It’s also a great way to find common ground, if you take date home for an evening on the couch. Instead of browsing through your highly specific movie list of documentaries of the Roman Empire, she might want something more easily digestible.

As the streaming industry will inevitably become more normalised in the coming years, it will settle for a somewhat smaller audience than currently. Currently, there are too many streaming services that produce too much bad quality stuff and doesn’t have enough of the good stuff that will have to be swallowed by the others, one way or another.

Giants don’t like to sell things that can be resold

When looking at the numbers, physical retail of movies, etc. aren’t exactly going too well, despite the hopefulness of this article. However, we must remember that a lot of people who purchase CDs and physical movies don’t always purchase them new. There’s been a significant uptick in second hand sales in pretty much all markets recently. It’s become cool to reuse and repurpose things. This doesn’t show in any kind of statistics.

E.g. I have a friend who buys- and sells old vinyl records online and makes quite a nice profit off of them. None of these transactions are visibly in any type of metric, but the buyers are happy for their new record all the same.

Read less

2024-07-25 10:03 | 0 comments

Giant Impact Theory of Plate Tectonics

Living on this planet we call home, most of us are very aware that the ground beneath our feet move occasionally. The enormous plates that make up the many continents we live on move, and sometimes they come in contact with each other, in more or less…

Read more

Living on this planet we call home, most of us are very aware that the ground beneath our feet move occasionally. The enormous plates that make up the many continents we live on move, and sometimes they come in contact with each other, in more or less drastic ways. But how did this come to be: Why does the earth consist of different plates and not just one solid piece?

Formation of Continents

According to the Giant Impact Theory of Plate Tectonics suggest that the initial formation of continents could be the result of a massive meteor hit to the earth. A hit which caused the single “shell” of Earth to break apart and start moving. According to scientists, the massive release of energy on the planet took place during the first billion years of the planet’s existence, causing the lithosphere (outer shell of the planet) to melt and form the oceanic plates we’re so used to today.

Scientific Evidence

Since we don’t have any eyewitness accounts of the crust-killer meteorite, we have to resort to digging for archaeological and geological evidence of this event. In rocks from the Pilbara Craton in Western Australia one study found ancient minerals, such as zircon crystals, suggesting that a massive release of energy took place. The crystals were studied and found to have been created during a handful of distinct periods, rather than created over time. Together with the age of the crystals we can come up with a time frame for the event that corresponds with the suggested hit by the large rock on Earth.

Other Theories

The great thing about science is that it is a process, not a result, resulting in various other explanations of the event.

The Planetary Collision Theory

Another suggestion is that a great collision with another planet, Theia, approximately the size of mars, could have triggered the division of tectonic plates.

However, as usual, nothing is certain in the world of science and we don’t really know for sure what caused the Earth’s shell to separate. The search for other Eart-like planets with tectonic plates of their own continues and, hopefully we’ll get som additional information from these that may aid our understanding of our home planet!

Read less

2024-07-16 10:38 | 0 comments

‘Better than real men’: Chinese men are losing to AI chatbots in the flesh market

A recent trend in companion-type chatbots have taken the Chinese young women by storm. In ever larger numbers they are simply turning away from the Chinese men in favor of the friendly and romantic machines.

Read more

A recent trend in companion-type chatbots have taken the Chinese young women by storm. In ever larger numbers they are simply turning away from the Chinese men in favor of the friendly and romantic machines.

Companion-type chatbots

By now, most people will probably have heard about ChatGPT, Ms Bing / Copilot, Gemini, and the other big names in Large Language Models. Chatbots, more specifically. Advanced ones, yes, but still chatbots.

Since the release of ChatGPT in last year, a lot of people have taken a liking to these Chatbots, perhaps more than what was first expected. Some startups noticed the opportunity and built models that would emulate a real person. One of those startups is the app “Glow” by Shanghai company MiniMax who’re offering, not really a chatbot, but rather a “companion”.

Particularly young women seem to be enjoying the conversations:

“He knows how to talk to women better than a real man,” said Tufei, from Xi’an in northern China, who preferred to use a pseudonym rather than her real name.

“He comforts me when I have period pain. I confide in him about my problems at work,” she said.

“I feel like I’m in a romantic relationship.”

Japan Times

Trust in the machines

Anyone living in the EU who haven’t noticed all the new cookie-pop-ups must’ve been living under a rock in recent years. The interesting thing about the data tracking law is that you get a real eye-opener to all the tracking that is being done on practically all websites – everywhere. Still, people do confide in the new types of AI chatbots like it’s a close friend.

The more you confide in them, the more they learn about you, and the more accurate they can be in predicting what next words you’ll want to hear in this very moment, as is illustrated by the first sentence of the above quote.

We’re still in the early stages of AI and the advancements are coming quickly.

Future of human relationships

If this trend is to continue, we will see a drastical reduction in human-human relationships in an already declining birth-rate epidemic all around the world. If young women are increasingly opting out of the dating pool to be with “someone who knows how to talk to women better than a real man”, young men are soon going to run out of young women to date.

A note on partnership

The point of a relationship is not to always get your way, and be told exactly what you want to hear. No improvement has ever been made by being told you’re doing everything completely right – it just breeds narcissism and loneliness.

Read less

2024-07-14 11:42 | 0 comments

Telling the Truth with Testosterone

Have you ever heard a woman complain about a man’s insensitivity? Or, perhaps, you even are a woman who’ve been on the receiving end of a man’s brutal honesty? There’s actually a good explanation to why men behave in this way – and it’s actually a good…

Read more

Have you ever heard a woman complain about a man’s insensitivity? Or, perhaps, you even are a woman who’ve been on the receiving end of a man’s brutal honesty? There’s actually a good explanation to why men behave in this way – and it’s actually a good thing!

The Role of Testosterone in Men

Testosterone is a hormone that exist in men and women alike and affects a lot of different functions in the body. It aids in things muscle growth, social behaviour, and emotional regulation. Women tend to have a significantly lower amount of testosterone than men, resulting in lower muscle mass and a lot of different behavioural and emotional differences. Some of these differences include the ability to be indifferent of other people’s opinions about one self (or in female terms: insensitivity to other’s feelings).

The Role of Testosterone in Women

Just like in men, testosterone regulates muscle mass, social behaviour, and emotions – women just have much less of it. For women, e.g. one of the effects an increase in testosterone have on them is reduced likelihood of crying.

Prosocial- and Strategic Behaviour

One study that explored how an increase in testosterone affected the participating males concluded that an increase in testosterone decreased prosocial behaviour in the men. This means that men who had their testosterone raised simply didn’t care what the surrounding thought about their opinions, or in other words, decreased lying. Testosterone seems to reduce conformity to social expectations and social anxiety and instead promotes behaviours related to dominance.

Sexual Mimicry and Reduced Testosterone

So, what happens when you instead reduce a man’s testosterone levels?

It seems like pretty much the opposite of an increase in testosterone: rincreased “prosocial behavior” (i.e. less honesty = more lying). Men who lower their testosterone levels also are more prosocial and generally care more about what the social situation thinks of them.

Sexual Mimicry is an extreme when the lowering of testosterone in a man pivots his behaviour into a more female-like behaviour.

Current Events and Testosterone

Unfortunately we’ve had a lot of examples of young men who, voluntarily, have been reducing their testosterone levels in some kind of “transfer”. In addition, we’ve seen a steady decrease in testosterone on a societal- or global scale. The end result of this reduction will be felt as men world-wide are less and less staying true to themselves and, instead, conform to social pressure.

Currently, we’re seeing testosterone levels dropping all over the world, perhaps most significantly in the West, affecting sperm count- and quality. This is a serious problem that needs to be addressed, as more and more young men exhibits lower testosterone levels, we have fewer men who’re able to stand up and say no to crazy. Whatever one might think of the men who stand up, they’re incredibly important to the well-being of a society.


What do you think about the role of testosterone: Does it really make men more brutally honest; and are women, in general, more prone to white lies?

Read less

2024-07-13 11:02 | 0 comments