• Resolved vigneshbabuor

    (@vigneshbabuor)


    Hi There,
    i have created a custom post type in wp_post by code. trying to map that custom post type in fieldmaps.
    when i trigger below code, post record is created but wordpress object dropdown field is not showing this post type, also did a clear cache.
    is there any option to check why is this happening to me? please suggest me.

    $post_args = array(
    ‘post_content’ => $surname,
    ‘post_type’ => ‘create-sp-post’,
    ‘post_excerpt’ => $sf_user_account_id,
    ‘post_title’ => $email,
    ‘post_author’ => $user_id,
    ‘post_name’ => $name,
    ‘post_status’ => ‘draft’,
    ‘post_content_filtered’ => true
    );
    $contact_id = wp_insert_post( $post_args );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jonathan Stegall

    (@jonathanstegall)

    It sounds like you still need to create the new custom post type. Once you do that, create an instance of that post type (that is what your code does) and clear the plugin cache, it will show up in the dropdown.

    // Our custom post type function
    function create_posttype() {
    	register_post_type(
    		'create-sp-post',
    		// CPT Options
    		array(
    			'labels' => array(
    				'name'          => __( 'Tests' ),
    				'singular_name' => __( 'Test' ),
    			),
    			'public'      => true,
    			'has_archive' => true,
    			'rewrite'     => array(
    				'slug' => 'tests'
    			),
    			'show_in_rest' => true,
    		),
    	);
    };
    // Hooking up our function to theme setup
    add_action( 'init', 'create_posttype' );
    
    Thread Starter vigneshbabuor

    (@vigneshbabuor)

    Thanks Jonathan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘custom post type is not listing in wordpress object field’ is closed to new replies.