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:
https://www.loom.com/share/8b1a8cdc0282401e8a45d2043867c196
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 custom block created with ACF:
acf_register_block_type(array(
'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.
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: https://www.loom.com/share/ae811648893d4251bb2e8ef5c9851ad7
but i don’t see/understand the difference of the posts
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
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.