• I have a field associated with taxonomy term ‘category’ that displays content on the category’s archive page. On archive pages where there are posts associated with that category, the field displays the content correctly. However, when viewing a category that has no posts associated with it, the field displays the incorrect content. I’m not even sure how it’s picking up the incorrect content.

    Below is the code I have on my category.php theme page:

    if ( is_category() ) {
    	$curcategory = get_the_category();
    	$title = single_cat_title( '', false );
    	$subtitle = category_description();
    	$curcatID = intval($curcategory[0]->term_id);
    	$taxonomy = 'category';
    	$issuu_embedcode = get_field('issuu_embed_code', $taxonomy . '_' . $curcatID);
    	}
    ?>
    	<h1 class="page-title title title-large"><?php echo $title; ?></h1>
    	<?php if ( ! empty( $subtitle ) ): ?>
    		<h2 class="subtitle"><?php echo $subtitle; ?></h2>
    <?php endif ?>
    <div align="center" style="margin-left: 0; margin-right: 0;"><?php echo $issuu_embedcode; ?></div>

    https://wordpress.org/plugins/advanced-custom-fields/

Viewing 1 replies (of 1 total)
  • That’s curious, because if a category term doesn’t have any posts associated to it, then it should display a Not Found page (the content-none template). Perhaps if you’ve made some changes to this default behaviour, that may be affecting the ACF output… Just a thought.

Viewing 1 replies (of 1 total)
  • The topic ‘Field Not Showing Correctly on Empty Taxonomy Term’ is closed to new replies.