Stephanie Leary

Writer and WordPress consultant

  • Books
    • Content Strategy for WordPress (2015)
    • WordPress for Web Developers (2013)
    • Beginning WordPress 3 (2010)
  • Blog
    • Fascism Watch (2016-17)
    • Content Modeling for WordPress series
    • WordPress Hidden Gems series
  • Work
    • Portfolio
    • Services
    • WordPress Plugins
    • WordPress Themes
    • Presentations and Interviews
    • on GitHub →
  • About
    • Press Kit
  • Contact
    • Mailing List

Content modeling for WordPress, part 3: a sample content model

July 29, 2013 Stephanie Leary 3 Comments

On fazd.tamu.edu, we found that in addition to the standard pages and posts, we had three distinct things: research projects, tools (the tangible items created during past research projects, like software suites or new vaccines), and people. These will become our custom post types.

For the research projects, we need to display a few things as distinct fields: the start and end dates of the grant, and the amount of money awarded for the research.

The tools don’t have dates or money attached anymore, but there is a photo or screenshot we can use to represent each one. We don’t need a custom field for that, though — the built-in featured image will be fine. We just need to enable featured images in the theme.

For people, we’ll use the post title field to store the full name, with appended degrees, as it will be displayed in most situations. (I’ll tweak WordPress’s built-in prompt to help the site’s content authors get this right; I’ll talk more about that in a minute.) However, we do need to alphabetize lists of people, so we need to break out their last names into a separate custom field. Their contact information (phone, email, URL, maybe a Twitter handle) should also go into separate fields so we can pull those into a staff directory. The post body will do just fine for the person’s bio, and and the featured image can store their portrait.

Here’s a diagram of the complete content model:

fazd-content-modelThe items in yellow (projects, tools, people) are the post types. The custom fields are listed beneath each post type’s name. The big curved arrows between the post types represent the Posts2Posts connections. The smaller arrows represent the taxonomies’s relationships to the custom post types. Each taxonomy (shown here as a white checkbox list) is shared by at least two post types. Institutions is a taxonomy shared by all the post types: for tools and research projects, it represents the research groups that have partnered on the project. People are listed under each institution for which they work — there might be more than one, in cases of dual academic appointments.

This diagram is slightly simplified — the site actually has two more taxonomies and another (unrelated) custom post type.

So here’s what we’re going to build over the next few posts in this series:

Custom post types:

  • projects
  • tools
  • people

Custom taxonomies:

  • institutions (for projects, tools, and people)
  • topics (for projects and tools)

Custom field groups:

  • Research project information (for projects)
    • Start date
    • End date
    • Award amount
  • Name and job title (for people)
    • Last name
    • Job title
  • Contact information (for people)
    • Phone number
    • Email address
    • URL
    • Twitter handle

Tweaking WordPress’s Prompts

Consider what a “people” post type (hereafter referred to as a person) will look like in the Dashboard. It’ll be a regular post with a title and body field. We plan to use the post title for the full name. However, there’s also a custom field that will contain a job title. That could be confusing for someone who doesn’t use WordPress on a regular basis, especially because the default placeholder text in the post title box says “Enter title here.”

We can change that!

In “Mangling Strings for Fun and Profit,” core developer Peter Westwood shows us how to change WordPress’s built-in text by taking advantage of its translation features. Bad news: it does require you to write some code. Good news: you can just cut and paste from Peter’s example, replacing the old and new phrases with the ones you want.

I’m skipping ahead a little bit here, so for now just know that we’re going to use “people” as the name of our custom post type for people. And here’s how we would change the title field’s placeholder/prompt on the people editing page, but not regular posts or pages:

// Change placeholder text on edit/add Person page
class FAZD_Translation_Mangler {
  function filter_gettext($translation, $text, $domain) {
    global $post;
    $translations = &get_translations_for_domain( $domain );
    if ( $post->post_type == 'people' && $text == 'Enter title here' ) {
      return $translations->translate( 'Enter full name here' );
    }
    return $translation;
  }
}
add_filter('gettext', array('FAZD_Translation_Mangler', 'filter_gettext'), 10, 4);

Here’s the result:

placeholder-2

There are lots of little things like this that you can tweak in order to clarify or simplify the editing screens for your custom post types.

In the next post, I’ll show you the code you need to start building the post types!

WordPress for Web Developers (9781430258667)

If you want all the code right this minute, grab my new book, WordPress for Web Developers. The final chapter walks you through the complete process of building custom post types, taxonomies, and fields.

Featured, WordPress content strategy

Comments

  1. Aaron Eaton says

    July 29, 2013 at 12:40 pm

    Wow. I really like that string mangler. In the past I’ve always removed title support for the CPT and saved one of the metaboxes as the title using the ‘title_save_pre’ filter. This solution will definitely come in handy.

    Reply
    • Stephanie Leary says

      July 29, 2013 at 1:31 pm

      Isn’t it nifty? You do have to be careful with it. I once forgot to return a value, and all the month names disappeared from the dates. (I guess those were the only things being translated.)

      Reply
  2. Yoav says

    August 24, 2013 at 6:01 am

    Thank you for the 3 parts. I also read chapter 4. So now it’s time for da book!

    Reply

Leave a Reply Cancel reply

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

Latest WordPress Book

Content Strategy for WordPress

A short book for content strategists and managers on implementing a complete content strategy in WordPress: evaluation, analysis, content modeling, editing and workflows, and long-term planning and maintenance.

Read the sample chapter

Kindle Nook iBooks Kobo Smashwords

WordPress for Web Developers

WordPress for Web Developers (9781430258667)

This is a book for professional web designers and developers who already know HTML and CSS, and want to learn to build sites with WordPress. The book begins with a detailed tour of the administration screens and settings, then digs into server-side topics like performance and security. The second half of the book is devoted to development: learning to build WordPress themes and plugins.

This is the second, much-revised and updated edition of Beginning WordPress 3, with a more accurate title. Everything’s been updated for WordPress 3.6.

WordPress for Web Developers is out now. See what's inside...

The best WordPress features you’ve never noticed

  • WordPress Hidden Gems: Screen Options
  • WordPress Hidden Gems: Bulk Edit
  • WordPress Hidden Gems: Private Status
  • WordPress Hidden Gems: Dashboard Feed Readers
  • WordPress Hidden Gems: Options.php

Content Modeling for WordPress series

  • Content modeling for WordPress, part 1: analyze content
  • Content modeling for WordPress, part 2: functional and organizational requirements
  • Content modeling for WordPress, part 3: a sample content model

This is an excerpt from Content Strategy for WordPress.My latest books are Content Strategy for WordPress (2015) and WordPress for Web Developers (2013). Sign up to be notified when I have a new book for you.

Copyright © 2022 Stephanie Leary