ACF Relationship – Different layouts for CPT

Question

I’m using an ACF relationship-field to choose items to show on a page. I have different custom post types (i.e. ‘Reizen’ and ‘Accommodaties’) which have different layouts. I’m trying to setup a way to just choose whatever post you like to show on the page and not needing to create a different relationship field per post type.

This is what I have so far. It works for categories, but I can’t get it to work for post types. I get no output for those. What am I missing here? Thank you!

<?php foreach( $featured as $featured_post ): 

    $featured_id = $featured_post->ID;

    $permalink = get_permalink( $featured_id );
    $title = get_the_title( $featured_id );
    $backgroundImg = get_field( 'hero_photo', $featured_id );
    $meta = get_field( 'reis_meta', $featured_id );

    if ( is_singular( 'reis' ) ) { ?>
    ...
    <?php } 


    if(has_category('uitbreidingen', $featured_id)) { ?>

        .....

    <?php } 


    if( is_singular( 'reis' ) ) { ?>

        .....       

<?php } endforeach; ?>
0
Thijs Wehrmeijer 2 months 0 Answers 16 views 0

Leave an answer