Support

Account

Home Forums General Issues Taxonomy field name and archive url / link

Helping

Taxonomy field name and archive url / link

  • I’m using advanced custom fields taxonomy field to select a particular term of a custom taxonomy. I can generate the term ID based on the field but I can’t display the link or the name of the term. Below is the code that I have that is generating a blank page

    
    <?php if(get_field('expertise_projects')): ?>
    
    <ul class="row expertise_projects">
    
      <?php while(has_sub_field('expertise_projects')): ?>
    
    <li  class="col span_3">
    
    <?php 
    
    $term_id =  get_sub_field('expertise_category');
    $term_link = get_term_link( $term_id, 'expertise' );
    echo '<a href="' . $term_link . '">View cat</a>'; 
     ?> 
    
    <?php
     
    $post_object = get_sub_field('expertise_project');
     
    if( $post_object ): 
     
      // override $post
      $post = $post_object;
      setup_postdata( $post ); 
     
      ?>
    
    <?php if ( has_post_thumbnail()) : ?>
      <a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail('our_work');?></a>
     <?php endif; ?>
    
                <h4><a href="<?php the_permalink(); ?>" <?php if ( !has_post_thumbnail()) : ?>class="large_title" <?php endif; ?>><?php the_title(); ?></a>
    
    <?php if( get_field('client_name') ): ?><span><?php the_field('client_name');?></span><?php endif; ?>
                </h4>
                    
                </li>
    
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>            
    
      <?php endwhile; ?>
    
    </ul>
    
    <?php endif; ?> 
  • Hi @jshindler

    Can you please debug the value of both $term_id and $term_link like so:

    
    <?php 
    
    echo '<pre>';
    	print_r( $term_link );
    echo '</pre>';
    die;
     ?>
    

    What values do you get for both variables?

    Thanks
    E

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

The topic ‘Taxonomy field name and archive url / link’ is closed to new replies.