Home Forums ACF PRO ACF Pro: Relationship Field does not accept/ save CPT


ACF Pro: Relationship Field does not accept/ save CPT

  • Hi there,
    i think i am a very experienced WP-Dev and i used to work with ACF since many years. WP and ACF are up to date.
    I have a Relationship-Field which does not accept or save my CPT selection. I created a loom for that:

    This is my CPT:

    register_post_type( 'event', array(
    		'labels' => array(
    			'name' => 'Events',
    			'singular_name' => 'Event'
    		'public' => true,
    		'publicly_queryable' => true,
    		'has_archive' => false,
    		'show_in_nav_menus' => true,
    		'show_ui' => true,
    		'show_in_rest' => true, // enables gutenberg
    		'rewrite' => array( 'slug' => _x( 'event', 'URL slug', 'hns' ) ),
    		'menu_icon' => 'dashicons-calendar-alt',
    		'supports' => array( 'title','editor','excerpt', 'thumbnail','revisions','custom-fields' ),
    ) );

    This is my ACF Field:

    This is my custom block created with ACF:

    			'name'              => 'hns_teaser',
    			'title'             => __('Teaser','hns'),
    			'description'       => __('Vorschau-Kachel für Beiträge erzeugen','hns'),
    			'render_template'   => 'template-parts/blocks/teaser/index.php',
    			'category'          => 'widgets',
    			'icon'              => 'images-alt2',
    			'keywords'          => array( 'teaser','post' ,'Beiträge','Vorschau'),
    			'mode'              => 'preview',
    			'supports'          => array(
    				'align'     => false,
    				'align_text' => true,
    				'multiple' => true,
    				//'align_content' => true, // oben, mittig, unten

    is there any explanation for the weird behavior? i mean i used it several times last month with many CPTs. Now i created a new one and it does work any longer.

    • WP_DEBUG is enabled and debug.log file empty
    • tested with 5.9.0, 5.10.1 and 5.11-RC1
  • one thing i tested: as it used to work with older/other CPTs, i duplicated one post of other CPT and then changed the posttype in the database to “event” and voila, it gets accepted and saved by the relationship field:
    but i don’t see/understand the difference of the posts

  • WOW finally i found the issue. It occurs when you use Polylang and you did not put the CPT in CPT-settings of the plugin:
    i simply forget it and this was driving me crazy for hours. JC! hopefully one day i can help someone with that monologue or ACF team will implement a fix

  • if you want to NOT have the cpt translatable by polylang you need to skip it in parse_query hook like this:

    function skip_cpts( $query ) {
    	if ( get_post_type() == "event" )  $query->set( 'lang', '' );
    add_action( 'parse_query', "skip_cpts", 0 );

    thanks to polylang support if found this solution helpful

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.