• Solution. Support. Expertise
  • +43 664 635 1238
  • +1 647-947-4502
  • info@tdwebservices.com
The Easiest Way To Create WordPress Custom FieldsThe Easiest Way To Create WordPress Custom FieldsThe Easiest Way To Create WordPress Custom FieldsThe Easiest Way To Create WordPress Custom Fields
  • Hosting
    • Hosting
      • Business Hosting
      • Enterprise Hosting
      • TDWS VPS
      • Managed WordPress Hosting
      • Highly Optimized WordPress Hosting
      • Laravel Hosting
      • Odoo Hosting
      • Moodle Hosting
      • TDWS Reseller Plans
    • E-Commerce Solutions
      • Managed WooCommerce Hosting
      • Highly Optimized WooCommerce Hosting
      • Magento Hosting
      • PrestaShop Hosting
      • OpenCart Hosting
    • Dedicated Servers
      • Gaming Servers
    • TDWS Global Monitoring System
      • Server Monitoring
      • Network Monitoring
      • Application Monitoring
      • Database Monitoring
      • Cloud Monitoring
      • Container Monitoring
      • Storage Monitoring
  • Cloud
    • TDWS Cloud
      • TDWS Cloud Servers
      • TDWS CloudSites
      • TDWS Box Cloud
      • TDWS Virtual Private Cloud
      • TDWS Cloud Drive
    • TDWS Private Cloud
      • KVM Hypervisor Private Cloud
      • Xen Hypervisor Private Cloud
      • Microsoft Hyper-V Private Cloud
      • VMware ESXi Private Cloud
      • VMware Public Cloud Servers
    • Services
      • DB as a Service
      • Disaster Recovery as a Service
    • Other
      • TDWS Cloud Infrastructure
      • TDWS Hybrid Cloud
  • Insights
    • Small Business
    • Knowledge Base
    • Cloud Computing
    • Expert Opinion
    • Industry debates
    • Thought Leadership
  • About Us
    • Why Us
    • Data Centers
    • Affiliate
    • TDWS Channel Partners
    • Contact Us
    • TDWS Customer Reviews
    • TDWS Video
    • Legal
      • TD Web Services Acceptable Use Policy (“AUP”)
      • TDAG DMCA Notice Policy
      • TDAG Privacy Policy
      • Master Service Agreement
      • Service Level Agreement
Login
✕
How can a Small Business Obtain an Online Presence?
16 July 2014
How low-cost computing can save your small business money
17 July 2014

The Easiest Way To Create WordPress Custom Fields

Published by TDWS Technical Support on 17 July 2014
Categories
  • Knowledge Base
  • Q&A
Tags
  • WordPress

WordPress affords website owners with the necessary fields that enable them to easily publish pages and posts. Some of these fields include Category Options, Content Editor, Featured Images and Tags.

Unfortunately, these fields are not adequate to lodge particular cases. For instance, let’s assume you come up with a Book Listing site that will display the Author of the Book, the Publisher and the ISBN number. It is obvious that you will require some extra fields from the ones you already have so you can input other additional and relevant information.

The good news is that, WordPress is currently extensive than ever before. This provides developers with platform to create custom fields that carter perfectly suites any website requirements. These customizable fields could feature a general text input, dropdown menu, text area, calendar, color picker and mage up-loader. The purpose of this tutorial is to show you how to easily create WordPress custom fields. So let us get on.

Highly Developed Custom Fields

For a realistic example, let us consider creating a book-listing site. In order to easily create our custom fields, we will utilize plug-in known as Advanced Custom Fields invented by Elliot Condon. With this plug-in, we will not need to touch the code too much when creating the particular custom fields. Nevertheless, a specific code-level editing for the themed files is necessary in order to display the data that we have inputted into the specified fields.

Upon installing it, an additional new side-menu identified as Costumed fields. Simply go this very menu and click on the Add New button, and name the Group Fields. For instance, “Custom Settings”. See the screen shot below.

Custom Fields Group

You can also click on the ‘add fields’ button to create additional new custom fields, by naming the labeled filed as Author. Underneath it, you can also set the Field Name easily as Book_Author, which can later be used to call out or highlight the data regarding the Author or the book. In addition to this, other additional and optional fields can be set such as Field Instruction and the Placeholder Text.

Custom Field Creation

Thereafter, we can also come up with a set of other relevant fields such as page length, the Book language, the publisher and so much more.

other-custom-fields

The next thing we will need to do is to assign the specific group fields to highlight in the particular Post Types. This can easily be assigned with Page, Post, Page Templates and Attachments or setting rules that will incorporate other post types in general. In the subsequent example, I would like to highlight the fields to Book Post Type, so that you can easily come up with your own using this handy tool, GenerateWp.

post-type

After that, we then proceed to our very Book Post Type editing platform and then fill it up.

Presenting the data

Before we can proceed to the next step, because we dispensed the specific fields to custom post type, we will have to create a new file to highlight the content known as single-book.php. Our codes will also be put in this file.

Once we have populated all our custom fields, we will highlight them in the front-end through the_field( ) feature by the relevant name. For instance, the cord below shows the data from Author Book filed that we have successfully created above.

the_field('book_author')

 

It is indeed that easy. Moreover, if you desire to ensure that it should be displayed only when the data is presented, you could as well wrap it up with a Conditional Statement. For instance:

if( !emptyempty(the_field('book_author')) ) : the_field('book_author');
endif;

 

Given below are all the codes that we have managed to put together in single-book.php to showcase our book.

<div class="entry-content">
<?php if ( has_post_thumbnail() ) {
echo '<figure class="book-thumbnail">';
the_post_thumbnail('book-thumbnail');
}
echo '</figure>'; 
?>
<div class="book-info">
<h3 class="book-title"><?php the_title() ?></h3>
<p class="book-description"><?php the_content() ?></p>
<h4 class="book-details-title">Book Details</h4>
<div class="book-details">
<ul>
<li class="book-author"><span class="label">Author:</span> <?php the_field('book_author') ;?></li>
<li class="book-pub"><span class="label">Publisher:</span> <?php the_field('book_publisher') ;?></li>
<li class="book-pages"><span class="label">Length:</span> <?php the_field('book_pages') ;?></li>
<li class="book-lang"><span class="label">Language:</span> <?php the_field('book_language') ;?></li>
<li class="book-pubid"><span class="label">ISBN/ASIN:</span> <?php the_field('book_isbn_asin') ;?></li>
</ul>
</div>
</div>
</div>

 

With just a little fashioning using CSS, we can easily come to the following subtle and neat achievement.

Closing thoughts

Within the tutorial, we have articulately guided you through the fundamental example of utilizing Advanced Custom Fields Plug-in to establish your individual set of new Texts Fields and easily dispense them to a Custom Post Type.

Besides that, the plug-in provides a variety of custom fields to boost our website including Text Area, WYSIWYG Editor, User List Options, Drop Downs and Google Maps among others. You can as well further explore the plug-in and consider the cool inventive you can accomplish.

Share
0
TDWS Technical Support
TDWS Technical Support

Related posts

man in white dress shirt sitting on black rolling chair while facing black computer set and smiling

Photo by Andrea Piacquadio on Pexels.com

6 March 2023

The Power of Plus Addressing


Read more
15 June 2021

Why Upgrade Your Site to PHP 7.x


Read more
27 May 2021

Common Causes Why is WordPress Slow


Read more
4 April 2021

HOW TO INSTALL WP-CLI?


Read more
11 June 2019

What is Plus Addressing?


Read more
27 May 2019

WordPress Acceleration using NginX Reverse Proxy & Caching


Read more
12 March 2019

How to Switch Your Domain Name Without Damaging Your Site’s SEO


Read more
10 March 2019

How to Use the cPanel/WHM Transfer Accounts Tool


Read more

Leave a Reply Cancel reply

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

Our Services

  • Business Hosting
  • TDWS VPS
  • Dedicated Servers
  • E-Commerce Solutions
  • Enterprise Hosting
  • Managed WordPress Hosting
  • Highly Optimized WordPress Hosting
  • SSL Certificates

TDWS Cloud

  • TDWS Cloud Servers
  • TDWS CloudSites
  • VMware Public Cloud Servers
  • VMware ESXi Private Cloud
  • Microsoft Hyper-V Private Cloud
  • TDWS Virtual Private Cloud
  • Hybrid Cloud
  • Cloud Infrastructure

Recent Posts

  • The Power of Plus Addressing
  • Why an LMS is Essential for Selling Courses Online
  • CentOS Stream vs AlmaLinux: Which Distribution is Right for You?
  • De-Risk Your IT Strategy with TDWS High-Performance Cloud
  • Speeding Up Success: How Power Day Sale Improved Website Performance and Increased Conversions

About Us

  • About Us
  • Why Us
  • Affiliate
  • Contact Us
  • Data Centers
© 2021 TD Web Services. All Rights Reserved.