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

Edit away your flaws with new DNA-editing CRISPR-technique, powered by AI

Have you dreamed about what it would’ve been like to be rid of all your bad habits and features? A disease that runs in the family, or perhaps your inability to digest milk without letting the whole room know about it.

Read more

Have you dreamed about what it would’ve been like to be rid of all your bad habits and features? A disease that runs in the family, or perhaps your inability to digest milk without letting the whole room know about it.

Embryo selection

I recently published another note about embryo selection and gene editing and how the company Orchid currently is undergoing trials to allow you to select what specific embryo you want to turn into a real baby. This allows for reducing the risks of the child to have certain weaknesses, like allergies and likelihood of getting different types of cancer, blindness, etc.

Gene editing and AI

So far, however, the only intervention made is picking between naturally developed embryos and scanning them for “defects”. The next step toward the “brave new world” is to actually go into the DNA of the cell and copy paste the kinds of genes you want to promote in there. In what might be our last step, as humanity, is to let an AI, or LLM do it for us:

“Our LLMs were trained on massive scale sequence and biological context to generate millions of diverse CRISPR-like proteins that do not occur in nature, thereby exponentially expanding virtually all known CRISPR families at-will.”

Sauce

Should we let AI write the code in humans?

This seems like a bad idea on the face of it. It’s one thing to use AI to enhance us by assisting us with tasks we’re not built for. It’s a completely different thing to actively let AI decide what our children should look like, behave like, and what illnesses they should be susceptible to.

I’m not convinced it’s a good idea for us to go about editing genes to our liking. AI is not very good at the moment, despite being very impressive at summarising large pdf’s and articles. It will get better, however, and the better it’ll become, the less we will understand its capabilities.

Letting AI write some code for a small project today works just fine and is pretty harmless because any given programmer understand what it does. The better it become, the fewer people will understand, until that time it outperforms and outsmart even the brightest of humans.

The same will probably be true for editing our genetic code, not just computer code.

Read less

2024-04-30 05:55 | 0 comments

Asbestos Water Pipe for Clean and Pure Water

Yes, this was part of an old commercial movie from back in the days. Courtesy of Brian Roemmele on X we’re getting small glimpses into a life lost to time.

Read more

Yes, this was part of an old commercial movie from back in the days. Courtesy of Brian Roemmele on X we’re getting small glimpses into a life lost to time.

You can find the video following this link to the original X post.

Pure water, year after year

One really has to stop and consider things we perceive as truths. Time does a lot to our perspective. Like the commercial for using asbestos in pipes made for hauling drinking water to our homes. There will be a lot of things we look back at in horror that we take for granted to be good for us today. Likewise, there will probably be a lot of things in the future that we thought was bad for us that turns out to be essential to our well-being. Make sure to keep an open mind!

Disclaimer: Asbestos is in fact not considered good for you, your wife, or your car and should be avoided as much as possible.

Thing is… We don’t really know if we’re going to look back at the popular plastic PEX pipes the same way in 50 years.

Read less

2024-04-29 11:24 | 0 comments

Shrinking populations in Sweden and the West – What’s the problem?

What is causing the ever increasing decline in birth rates in the Western world? This is a question that all the more people are starting to ask themselves as populations all over the world are getting older.

Read more

What is causing the ever increasing decline in birth rates in the Western world? This is a question that all the more people are starting to ask themselves as populations all over the world are getting older.

The problem

For quite some time we’ve been aware of the trend that there’s more and more old people in today’s Western societies, while kids keep on getting fewer. In Sweden, there’s been many discussions on the care of old people, pensions being reduced, and a general lowering of living standard as fewer people each year must work to support a larger group of ageing parents.

Since the hysteria surrounding the Covid virus arose, there’s been those pointing out a steep reduction in new births. This is not only affecting the countries that had the worst lockdown, but affected pretty much every country that took part in the hysteria. Some people are pointing towards the vagscenes as culprit, while others claim a change in the way we socialise.

It’s much more likely a combination of vary many variables, such as lifestyle change, more females in the workforce, worsening economy, people waiting longer to have children, unhealthier diets, seed oils, obesity, chronical diseases, mental health, a more insecure world, etc.

I could keep going but the point is we’re getting more unhealthy, mentally and physically, while the surrounding world are giving us every incentive to wait with children and to not settle down.

Solutions?

Are there any solutions to this issue that our leaders could actually implement?

Yes, and no. The solution is part of the problem.

Many governments are implementing pro-family regulations and solutions to the population problem. Some, like Sweden, are giving great benefits to families, while others, like Hungary, reduces income taxation for every child a Hungarian mother gives birth to, to the extent that they may never pay income tax ever again in Hungary.

While these types of benefits are well-meaning and do a lot of good for the families, it doesn’t address the underlying problem. There’s no change in the declining birth rates, after all.

Other options

Hungary is on the right track, but instead of only giving the reduced income tax to the mother, give it to the family, making sure they stick together and honour their marriage. Don’t pressure the mother out into the work force if she wants to spend time with the kids. Instead, allow for the father to be able to support his family while the mother is pregnant and staying at home with their children.

Both the Hungarian and the Swedish family programs are currently both geared towards getting the mother back into the work force as quickly as possible while completely disregarding husband’s role.

Read less

2024-04-28 01:57 | 0 comments

Dentist finds human jawbone encased in parents’ travertine floor

During a visit to his parents’ recently renovated home in Europe, a dentist made a surprising discovery – a jawbone embedded in one of the bathroom floor tiles. And, no, it is not the kind with screen-print but the real deal, gathered from a real quarry.

Read more

During a visit to his parents’ recently renovated home in Europe, a dentist made a surprising discovery – a jawbone embedded in one of the bathroom floor tiles. And, no, it is not the kind with screen-print but the real deal, gathered from a real quarry.

The Discovery

The newly renovated floor used travertine, a naturally occurring stone that forms over long periods of time. This particular piece was likely quarried from Spain or Turkey, according to the Reddit thread. The time it takes for travertine to form makes the timeline anywhere between 24,000 years to 1.9 million years since the tragic departure of the jaw from the man.

Implications

Depending on the actual age of the fossilized jaw, this might have implications for dating our ancestry. By first sight, most of the alleged dentists scurrying to the Reddit thread, conclude it likely is a jaw from a modern human, i.e. homo erectus.

Bathroom industry’s coming response

In the bathroom industry, we’ve seen a rush among companies to sustainable and recycled materials. While this type of recycling probably isn’t what most are imagining, the answers to the thread indicate there’s a non-insignificant group of people who would pay many monies to walk on bones. Literally.

Any bathroom company worth its salt would immediately start to manufacture tiles, washbasins, toilets, and bathtubs with recycled human remains!

Think a faucet where the water exits through the index finger of a hand, called “The Deluge”.

Read less

2024-04-27 11:07 | 0 comments

AI generated scientific studies with AI simulated human participants new frontier in social sciences

Do we even need humans to study human behavior anymore or can we just simulate human response using AI? This is a question we soon must ask ourselves as AI technology takes new leaps forward. While opening up for research otherwise not possible…

Read more

Do we even need humans to study human behavior anymore or can we just simulate human response using AI? This is a question we soon must ask ourselves as AI technology takes new leaps forward. While opening up for research otherwise not possible, some suggest this is a dangerous path to walk.

The Study

Can AI and LLMs replace humans in social science studies to overcome limitations and biases inherent in traditional studies?

This is the question posed by the researchers, to which the answer is “kind of”. The researchers successfully managed to run the experiment with LLMs responsible for every step in the progress, introducing a new approach to testing scientific hypotheses.

They ran several different scenarios: a negotiation, bail hearing, job interview, and an auction. In all of the scenarios the LLM played all of the roles, of the tested, tester, analyzer, etc.

Implications

If we allow the system to act as both the test person and the ones running the tests, can we still claim to have tested our theories on humans?

While AIs and LLMs have become hauntingly good at impersonating humans, they are still not… human. Until we get AGI that can run experiments on us by itself, the AIs we create are simply as good as the data it’s tested on.

With that said, the LLMs of tomorrow (and to some extent of today) will simply have so much information about us to accurately predict our behavior better than we can. This will allow for incredibly easy and cheap access to automatically generated predictions and data on subjects that are hard or expensive to study right now.

The paper gives interesting insights into how social science research could be automated and improved in the near future, hopefully leading to many more interesting studies of ourselves as humans!

Read less

2024-04-26 11:07 | 0 comments