Support

Account

Home Forums General Issues Nested Relationships

Unread

Nested Relationships

    • xsd

    • November 18, 2020 at 9:41 am

    I have two categories of WooCommerce products: Enclosures and Cameras

    Each Enclosure entry has a relationship field product_cameras, where multiple compatible cameras are selected.

    Each Camera entry has a relationship field product_manufacturer, where a single manufacturer (post) is selected.

    My code will pull all the correct camera information, however, I can’t get it to pull any of the information for the manufacturer (it is displaying the title for the enclosure post instead).

    Any help is greatly appreciated!

    <?php
    $featured_posts = get_field('product_cameras');
    if( $featured_posts ): ?>
    <div class="row justify-content-left">
            <?php foreach( $featured_posts as $featured_post ): 
            $title = get_the_title( $featured_post->ID );
            $image = get_the_post_thumbnail_url( $featured_post->ID, 'thumbnail' );
            $pdf = get_field( 'product_spec_sheet', $featured_post->ID );
            $manufacturer = get_field( 'product_manufacturer', $featured_post->ID );
            $logo = get_field( 'manufacturer_logo-darkbg', $manufacturer );
            $manuname = get_the_title( $manufacturer );
            ?>
                <div class="col col-sm-3 pb-5"> 
                   <div class="card h-100 product-card product-card--camera clear-styles">
                        
    <div class="card-body product-card--image">
                     	<img src="<?php echo esc_html( $image ); ?>" class="pb-4">
    
     <img src="<?php echo esc_url( $logo['url'] ); ?>" style="max-height:25px;">
    <p><?php echo esc_html( $manuname ); ?> <?php echo esc_html( $title ); ?> 
    <?php if( $pdf ): ?>
    	  <a href="<?php echo get_site_url(); ?><?php echo esc_html( $pdf ); ?>" target="_blank"><i class="fas fa-info-circle"></i></a>
    <?php endif; ?>
    </p>
    </div>
                   </div>
                </div>
            <?php endforeach;  ?>
    </div>
    <?php endif; ?>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

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.