bbPress::register_post_types()

Setup the post types for forums, topics and replies

Description

Source

File: bp-forums/classes/class-bbpress.php

    public static function register_post_types() {

        /** Forums ************************************************************/

        // Register Forum content type
        register_post_type(
            bbp_get_forum_post_type(),
            apply_filters( 'bbp_register_forum_post_type', array(
                'labels'              => bbp_get_forum_post_type_labels(),
                'rewrite'             => bbp_get_forum_post_type_rewrite(),
                'supports'            => bbp_get_forum_post_type_supports(),
                'description'         => __( 'Forums', 'buddyboss' ),
                'capabilities'        => bbp_get_forum_caps(),
                'capability_type'     => array( 'forum', 'forums' ),
                'menu_position'       => 555555,
                'has_archive'         => bbp_get_root_slug(),
                'exclude_from_search' => true,
                'show_in_nav_menus'   => true,
                'public'              => true,
                'show_ui'             => current_user_can( 'bbp_forums_admin' ),
                'can_export'          => true,
                'hierarchical'        => true,
                'query_var'           => true,
                'menu_icon'           => '',
                'show_in_menu'        => false,
            ) )
        );

        add_post_type_support( bbp_get_forum_post_type(), 'thumbnail' );

        /** Topics ************************************************************/

        // Register Topic content type
        register_post_type(
            bbp_get_topic_post_type(),
            apply_filters( 'bbp_register_topic_post_type', array(
                'labels'              => bbp_get_topic_post_type_labels(),
                'rewrite'             => bbp_get_topic_post_type_rewrite(),
                'supports'            => bbp_get_topic_post_type_supports(),
                'description'         => __( 'Forum Discussions', 'buddyboss' ),
                'capabilities'        => bbp_get_topic_caps(),
                'capability_type'     => array( 'topic', 'topics' ),
                'menu_position'       => 555555,
                'has_archive'         => ( 'forums' === bbp_show_on_root() ) ? bbp_get_topic_archive_slug() : false,
                'exclude_from_search' => true,
                'show_in_nav_menus'   => false,
                'public'              => true,
                'show_ui'             => current_user_can( 'bbp_topics_admin' ),
                'can_export'          => true,
                'hierarchical'        => false,
                'query_var'           => true,
                'menu_icon'           => '',
                'show_in_menu'        => false,
            )
        ) );

        /** Replies ***********************************************************/

        // Register reply content type
        register_post_type(
            bbp_get_reply_post_type(),
            apply_filters( 'bbp_register_reply_post_type', array(
                'labels'              => bbp_get_reply_post_type_labels(),
                'rewrite'             => bbp_get_reply_post_type_rewrite(),
                'supports'            => bbp_get_reply_post_type_supports(),
                'description'         => __( 'Forum Replies', 'buddyboss' ),
                'capabilities'        => bbp_get_reply_caps(),
                'capability_type'     => array( 'reply', 'replies' ),
                'menu_position'       => 555555,
                'exclude_from_search' => true,
                'has_archive'         => false,
                'show_in_nav_menus'   => false,
                'public'              => true,
                'show_ui'             => current_user_can( 'bbp_replies_admin' ),
                'can_export'          => true,
                'hierarchical'        => false,
                'query_var'           => true,
                'menu_icon'           => '',
                'show_in_menu'        => false,
            ) )
        );
    }

Changelog

Changelog
Version Description
bbPress (r2597) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.