Home / Admin / GravityForms_DIR_AA_CPT – Gravity Forms & Feeds CPT Registration
Duplicate Snippet

Embed Snippet on Your Site

GravityForms_DIR_AA_CPT – Gravity Forms & Feeds CPT Registration

* Description: Registers custom post type with full REST API support
* Location: Run Everywhere
* Priority: 0

ismail daugherty PRO
<10
Code Preview
php
<?php
/**
 * WPCode Snippet: Gravity Forms & Feeds CPT Registration
 * Description: Registers custom post type with full REST API support
 * Location: Run Everywhere
 * Priority: 0
 */
defined( 'ABSPATH' ) || exit;
add_action( 'init', function() {
    $labels = [
        'name'                     => 'Forms & Feeds',
        'singular_name'            => 'Form & Feeds',
        'menu_name'                => 'GF Forms & Feeds',
        'all_items'                => 'All Forms',
        'add_new'                  => 'Add New',
        'add_new_item'             => 'Add New Form',
        'edit_item'                => 'Edit Form',
        'new_item'                 => 'New Form',
        'view_item'                => 'View Form',
        'search_items'             => 'Search Forms',
        'not_found'                => 'No forms found',
        'not_found_in_trash'       => 'No forms found in Trash',
        'item_updated'             => 'Form updated',
    ];
    
    register_post_type( 'gf_form_feeds', [
        'labels'              => $labels,
        'description'         => 'Gravity Forms with feed counts, settings, and comprehensive field details',
        'public'              => false,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'menu_position'       => 31,
        'menu_icon'           => 'dashicons-feedback',
        
        // REST API support - CRITICAL for WhalSync
        'show_in_rest'        => true,
        'rest_base'           => 'gf-forms-feeds',
        'rest_controller_class' => 'WP_REST_Posts_Controller',
        
        // Security
        'capability_type'     => 'post',
        'map_meta_cap'        => true,
        
        // Features - MUST include 'custom-fields' for meta exposure
        'supports'            => [ 'title', 'custom-fields', 'revisions' ],
        'hierarchical'        => false,
        'has_archive'         => false,
        'rewrite'             => false,
        'query_var'           => true,
        'exclude_from_search' => true,
        'can_export'          => true,
        'delete_with_user'    => false,
    ] );
} );

Comments

Add a Comment