Support

Account

Home Forums Front-end Issues Taxonomies not showing up when using Checkbox and Taxonomy field

Helping

Taxonomies not showing up when using Checkbox and Taxonomy field

  • Okay, this is my scenario:

    I have a taxonomy called comic_category.
    I’ve added two custom fields: border_color and tax_image
    I have them targeting “Taxonomy Term” is equal to “Comic Category”.

    Now I have a Front Page template and I want to show 3 of these taxonomies on the home page. So I’ve created a new Taxonomy field called home_categories.This field is targeting: “Page” is equal to “Home” and I’m using checkboxes to choose the three comic categories.

    The only problem, is nothing is showing up at all. I pretty sure my code is wonky. Here’s what I have:

    <?php 
    						
    						$terms = get_field('home_categories');
    						$term_link = get_term_link( $term ); 
    						
    						if( $terms ): ?>
    						<?php foreach( $terms as $term ): ?>
    
    								<div class="w-slide category-slide">
    		              <a class="w-inline-block" href="<?php echo $term_link ?>" data-ix="comic-blok">
    		                <div class="<?php echo get_field('border_color', $term); ?> category-block">
    		                  <div class="category-wrapper home"><img class="comic-image" src="<?php echo get_field('tax_image', $term); ?>" width="500" alt="<?php echo $term->name . ' category'; ?>">
    		                  </div>
    		                </div>
    		              </a>
    		              <?php echo '<div class="category-title">' . $term->name . '</div>'; ?>
    		            </div>
    		            
    		            <?php endforeach; ?>
    		            
    							<?php endif; ?>
    							
    							<?php wp_reset_query(); ?>
  • $term_link = get_term_link( $term ); could not work because $term is set inside the foreach loop. (dont think that is the main problem, but it would be one of the possibilities why it not work.)

    and you have “the same” a custom post that work with the others taxonomies?

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

The topic ‘Taxonomies not showing up when using Checkbox and Taxonomy field’ is closed to new replies.

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.