• Resolved Nico

    (@nico87)


    Hello community,

    I’ve been trying for a few days on my Post_Type “angebote” in the single view to display informations from my taxonomy “ansprechpartner”.
    For the “ansprechpartner” I created the input fields with ACF which I would then display in the single view of the “angebote” (multiple selections of “ansprechpartner” are possible and hierarchical).

    Do you have a code, help or something like that :)? I’m slowly despairing: P

    Thank you and everyone stays healthy
    Nico

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Nico

    (@nico87)

    Have found a solution… maybe someone need a working result:

    <?php 
    	$cat_array = ( get_the_terms( get_the_ID(), 'ansprechpartner') ); 
    	echo '<h4 class="label">Ansprechpartner</h4>';
        foreach ($cat_array as $cat ) : ?>
    		<?php //Vars
    			$ansprechpartnername = get_field('ansprechpartnername', $cat);
    		?>
    		<div class="single-ansprechpartner <?php echo $cat->slug; ?>">
    			<h5 class="title"><?php echo $cat->name; ?></h5>
    			<dl>
    				<?php if( $ansprechpartnername ): ?>
    				<dt class="label">Ansprechpartner:</dt>
    				<dd class="description"><?php echo $ansprechpartnername; ?></dd>
    				<?php endif; ?>
    				
    				<?php if( have_rows('ansprechpartner-anschrift', $cat) ): ?>
    					<?php while( have_rows('ansprechpartner-anschrift', $cat) ): the_row(); ?>
    				
    						<?php if ( get_sub_field('ansprechpartner-anschrift_ort') ): ?>
    							<dt class="label">Anschrift</dt>
    						<?php endif; ?>
    						<?php if ( get_sub_field('ansprechpartner-anschrift_strasse') ): ?>
    							<dd class="description"><?php the_sub_field('ansprechpartner-anschrift_strasse'); ?></dd>
    						<?php endif; ?>
    						<?php if ( get_sub_field('ansprechpartner-anschrift_ort') ): ?>
    							<dd class="description"><?php if ( get_sub_field('ansprechpartner-anschrift_plz') ): ?><?php the_sub_field('ansprechpartner-anschrift_plz'); ?> <?php endif; ?><?php echo the_sub_field('ansprechpartner-anschrift_ort'); ?></dd>
    						<?php endif; ?>
    				
    					<?php endwhile; ?>
    				<?php endif; ?>
    				
    				<?php if( have_rows('ansprechpartner-kontaktadressen', $cat) ): ?>
    					<?php while( have_rows('ansprechpartner-kontaktadressen', $cat) ): the_row(); ?>
    						<dt class="label"><?php the_sub_field('ansprechpartner-kontaktadressen-kontakt_beschriftung'); ?></dt>
    						<dd class="description"><?php the_sub_field('ansprechpartner-kontaktadressen-kontakt_wert'); ?></dd>
    					<?php endwhile; ?>
    				<?php endif; ?>
    				
    			</dl>
    		</div>
    <?php endforeach; ?>
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Looks pretty valid to me, based on my own ACF experiences and everything. Just a matter of fetching the right content type then outputting ACF data from that appropriately.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show specific taxonomy on single-post’ is closed to new replies.