PostTypes
  • PostTypes v2.2.1
  • Getting Started
  • PostTypes
    • Create a Post Type
    • Add Taxonomies
    • Filters
    • Columns
    • Menu Icons
    • Flush Rewrite Rules
  • Taxonomies
    • Create a Taxonomy
    • Add to Post Type
    • Columns
  • Notes
  • Contributing
  • Changelog
Powered by GitBook
On this page
  • Translations
  • Custom Fields
  • Examples

Notes

PreviousColumnsNextContributing

Last updated 6 years ago

Translations

Since 2.0 the translation() method has been removed. You can translate any labels and names when you assign them to the PostType or Taxonomy. It was removed to provide more control to the developer while encouraging best practices around internationalizing plugins and themes set out by .

// Translating the post types plural and singular names.
$books = new PostType( [
    'name'     => 'book',
    'singular' => __( 'Book', 'YOUR_TEXTDOMAIN' ),
    'plural'   => __( 'Books', 'YOUR_TEXTDOMAIN' ),
    'slug'     => 'books',
] );

// Translating labels.
$books->labels( [
    'add_new_item' => __( 'Add new Book', 'YOUR_TEXTDOMAIN' ),
] );

Custom Fields

The class has no methods for making custom fields for post types, use .

Examples

The books example used in the README.md can be found in .

WordPress
Advanced Custom Fields
examples/books.php