Custom post types allow developers to extend the Wordpress platform to allow for different types of content to plugins and themes. Simply stated, a custom post type is a special type of content defined by a web developer for a website. Web developers can define both the properties of that content and the design of the content for frontend users. Often times people are confused about the term "post type." Custom posts do not just imply blog posts, Wordpress comes with a number of default post types natively.
The Wordpress platform makes it easy to program new post (content) types and add them to a website. You will need to define the new post type inside the functions.php file inside your theme.
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'acme_members',
array(
'labels' => array(
'name' => __( 'Members' ),
'singular_name' => __( 'Member' )
),
'public' => true,
'has_archive' => true,
)
);
}
That's it. This statement creates a new post type called Member, which can be used to create a member database. This is the start of using Wordpress to develop a membership website. Certainly a lot more options can be added to our post type called "Member." The options can include setting Admin labels as well as adding additional fields. It is a good idea to prefix any post type created with a unique naming convention to prevent conflicts with other plugins.
Viewing the new post-type as an archive (list) page:
archive-{posttype}.php
This article is meant to be a quick reference for Wordpress web developers and not an extensive guide.
by Jonathan Franchell, CEO of Ironpaper - For more tips and hacks: Need to remove a new line after h1 tags? Both web designers and SEO practitioners need to employ headline tags: H1, H2, H3 in several ways to improve web page structure and tag...
The Crowded Arena of the IT Marketplace Updated December 2024 The Information Technology (IT) landscape is experiencing rapid growth and intensifying competition. IT spending is projected to reach nearly 5.1 trillion U.S. dollars in 2024, a...
Updated December, 2024 The field of digital marketing is evolving rapidly in response to new technology and changing buyer expectations. To help career-minded marketers, we’ve rounded up the top 10 skills needed to succeed in the field. These are...