• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Best way to create a custom post type using Genesis

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Best way to create a custom post type using Genesis

This topic is: not resolved

Tagged: CPT, Custom Post Type

  • This topic has 4 replies, 3 voices, and was last updated 2 years, 6 months ago by jesslerner.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • August 11, 2020 at 3:17 pm #500531
    jesslerner
    Participant

    Hello!

    To add a custom post type I created a PHP file in wp-content, mu-plugins. Is there a better or different way that works better with Genesis?

    I ran into a few snags on my website (not live yet), however, I think it's being caused by hosting issues and not my custom posts.

    Is there a better way to create a custom post type using Genesis?

    Thanks!
    Jess

    This is the code I'm using -

    <?php

    // Adding Parks Post Type ORIGINAL

    function realparks_post_types() {

    register_taxonomy(
    'park-type',
    'park',
    array(
    'labels' => array(
    'name' => _x( 'Park Type' ),
    'add_new_item' => __( 'Add New Park Type' ),
    'new_item_name' => __( 'New Park Type' ),
    ),
    'exclude_from_search' => true,
    'has_archive' => true,
    'hierarchical' => true,
    'rewrite' => array( 'slug' => 'parks', 'with_front' => false ),
    'show_ui' => true,
    'show_admin_column' => true,
    'show_tagcloud' => true,
    ));

    register_post_type('parks', array(
    'public' => true,
    'labels' => array(
    'name' => 'Parks',
    'add_new_item' => 'Add New Park',
    'edit_item' => 'Edit Park',
    'all_items' => 'All Parks',
    'singular_name' => 'Park'
    ),
    'menu_icon' => 'dashicons-palmtree',
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-layouts', 'genesis-cpt-archives-settings' ),
    'taxonomies' => array( 'park-type' ),
    ));

    }

    add_action('init', 'realparks_post_types');

    August 11, 2020 at 3:39 pm #500532
    Brad Dalton
    Participant

    Add the code to your child themes functions file or a MU plugin.


    Tutorials for StudioPress Themes.

    August 11, 2020 at 5:31 pm #500533
    jesslerner
    Participant

    Awesome, thank you for confirming.

    September 4, 2020 at 2:53 pm #500948
    Anita
    Keymaster

    I would use a plugin for sure for you CPT @jesslerner if you haven't already. If you go to switch themes at any point, if you don't carry that over to the next theme, you're going to lose the connection.


    Love coffee, chocolate and my Bella!

    September 8, 2020 at 9:53 am #500988
    jesslerner
    Participant

    Thank you! Yes, I used it as an mu-plugin. Greatly appreciate the assistance!

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble