Custom WordPress Sites Utilizing Custom Post types; why – and how to.

One of the biggest advantages of using  custom WordPress sites is to create different abstractions of within your data structure. For instance,if you were running a store, you would utilize a quote-unquote product post type, that can be added like you add a post on Facebook, or nearly as easily. This extends to all sort of possibility, some of which will be exploring here.

In a sense, all custom WordPress sites are the same!

Using custom WordPress sites is a bit of a misnomer, because all WordPress websites have the ability to be custom. Also, the ability to utilize custom post types and custom taxonomies in order to categorize your data website. All WordPress sites have access to the default WP Core toolkit which has built in functions to handle abstract but very necessary things like categorization of data at any level. In addition,it can handle completely different things like managing time. This is called the Cron jobs(scheduled tasks that run automatically on your server, built in to WordPress and waiting for you to hook into them!)

Custom WordPress Sites

Custom WordPress site using WooCommerce to manage eCommerce product, first half of the individual product setup page

How to set your WordPress site away from the others, custom post types and WP_Query

To utilize custom post Types on your custom WordPress site or more precisely register them somehow your WordPress site, is done using the built-in function register post type within the WordPress core. You can learn more about how to create some post types manually here. Creating custom post types for a custom WordPress site particularly hard to do. Many people elect to use a plug-in in order to visualize the creation of these post types. There are web-based tools also that will help you generate code to register your within your custom WordPress installation. You can include custom functions in your theme’s function.php file.

Example code for your Custom WordPress Sites

The WP_Query object is extremely powerful, after you register your custom post types or custom taxonomy you can grab them into a PHP object which can then be parsed as a normal PHP object in your script.This allows you to grab any data type and render it within any HTML/CSS/Javascript formatting you would like with fairly easily PHP boilerplate, see below:

<?php
//SET ARGUMENTS FOR PHP/WP QUERY OF PRODUCT POST TYPE
$args = array(
'post_type' => array( 'product' ),
);
//START HANDLING OF LOOP
// The Query
$query = new WP_Query( $args );
//START LOOP WITH QUERY
while ( $loop->have_posts() ) {
//CONTAINER WRAPPER FOR PRODUCT
echo "<div style='width:20%;float:left;min-height:300px' class='PRODUCTBOX'>";
//SETS THE CURRENT POST TO THE LOOPED POST OF THE WP_QUERY
$loop->the_post();
$perma = get_permalink();

echo "<img src='$img' style='height:200px'><br>";
echo "<a href='$perma'>";
the_title();
echo "</a>";
echo "</div>";

}

?>

Sound a bit innocuous as far as features go when you need a custom WordPress site for a CMS. Consider that nearly every large management or display plugin within WordPress will be using custom post types.

It is very easy to see how the scope of your website would go beyond the default WordPress post types. They are as follows: post, page, attachment, revision and navigation menu. So, if you would like it to manage galleries independently for you, you may install a plug-in like NextGen galleries. Or, create your own, using custom post types and fields to manage data in correlation to post IDs. You may also consider huge plugins such as WooCommerce, which is built upon custom post types as well, their products a post type. Yes that’s absolutely correct, the most popular WordPress plugin to do E-commerce and news business with, uss custom post types to manage data, which are at your disposal! Hopefully this post helps you to get creative with your custom WordPress site using custom post types.

Leave a Comment

Your email address will not be published.

RSS
LinkedIn
LinkedIn
Share
Instagram