Categories
Meeting Information

Custom Post Types & Custom Fields: Meeting Notes at The RocketLounge

Thank you to Peter & Dieter provide The RocketLounge as our new meeting space. We appreciate your hospitality and generosity!

I want to say that this was one of the best ones that I have been too so far. I love the fact that we can be more up close and personal at the new venue. — Ani

Informative MeetUp and met some great people too! — Marcy

Upcoming WordCamps and other WordPress Events

Mentioned during discussions

  • Eventful.com Live Event Feeds from Florida – They also have a Developer API to check out
  • Google Resizer – use to check how your site looks on different screen sizes.

Custom Post Types and Custom Fields made WordPress Enterprise ready

The WordPress Core Team introduced Custom Post Types in 2010 with version 3.0, and it made WordPress enterprise ready as a content management system for lots of different use cases beyond blogging and brochure-like websites.

Custom Post Types Solutions via plugins

Please share your favorite Custom Post Type plugin in the comments!  

Articles:

WordPress Codex resources

Plugins for Administrators & Developers

    • Custom Post Type UI – This plugin provides an easy to use interface to create and administer custom post types and taxonomies in WordPress. The plugin just creates the types. You will need to add them to the theme yourself.
    • Advanced Custom Fields – love it because of the repeater field in the pro version,
    • Custom Field Suite a visual custom fields management plugin.

Code Examples:

Display of Custom Fields (ACF) per custom post type.

Code, assuming you installed the  ACF plugin.

In your Theme:  If your Custom Post Type’s slug is ‘product’  – copy the single.php template from your theme and save it as single-product.php. WordPress will pick that template automatically.

 

Withing the loop add something like this, assuming ‘product’ is your custom post type and ‘applications’ and ‘twc_options’ are your custom fields, associated with the custom post type.

<code>

elseif ( is_singular( ‘product’ ) ){

if( get_field(‘applications’) ): ?>

<div class=”acf”>

<h2>Applications</h2>

<?php the_field(‘applications’); ?>

</div>

<?php endif;

if( get_field(‘twc_options’) ): ?>

<div class=”acf”>

<h2>Features and Benefits</h2>

<?php the_field(‘twc_options’); ?>

</div>

<?php endif;

}

 

For a custom post type taxonomy pages you can use the following WordPress core functions

function display_wirescables() {

echo( ‘<ul class=”wirecat”>’ );

foreach (get_terms(‘wires-cables’) as $cat) :

echo( ‘<li>’ );

echo( ‘<a href=”‘ . get_term_link($cat->slug, ‘wires-cables’) . ‘”>’ .  $cat->name . ‘</a>’ );

echo( ‘</li>’ );

endforeach;

echo( ‘</ul>’ );

}

</code>

By Birgit Pauli-Haack

web & mobile developer for biz + nonprofits in Naples, Florida. WordPress Meetup SWFL organizer, Netsquared organizer, #nptech, photographer.
Owner Pauli Systems, Naples , FL & co-founder NPTechProjects - Improving Nonprofit Impact through Technology
Birgit is also a deputy on the WordPress Global Community Team

Leave a Reply