Support

Account

Home Forums General Issues Trying to display a category (taxonomy) field in the fronted Reply To: Trying to display a category (taxonomy) field in the fronted

  • I am in trying to call the category in the template part file:
    X:\wp-content\themes\wp-bootstrap-starter\template-parts\content-plan.php

    The template part is then called in a single page file I created for showing only one “plan” in the frontend:
    \wp-content\themes\wp-bootstrap-starter\single-plan.php

    Every fields are appearing in a single plan page on the frontend, appart the category taxonomy selected for the plan in question (plan_type field in ACF).

    Template part code:

    <?php
    
    /**
     * Template part: Plan
     */
    
    if ( !function_exists( 'get_field' ) ) 
    	return;
    ?>
    
    	<h1><?php the_title(); ?> plan</h1>	   
            <ul>
                  
                  <li>Host : <?php 
                    
                $companyname = get_field('companyname');
                echo get_the_title( $companyname->ID );
                
                
                ?>
                  </li>
                <li>Plan type : <?php the_field('plan_type'); ?></li>
    	       <li>Monthly price : $ <?php the_field('monthly_price'); ?></li>
                
                  <li><?php the_field('company_location'); ?></li>
                
                </ul>
                <p><?php the_content(); ?></p>
                
                
            
            
    	</div><!-- .entry-content -->
    </article><!-- #post-## -->

    Single page code (I know it’s not the right way to call the plan_type):

    <?php
    get_header(); ?>
    
    	<section id="primary" class="content-area col-sm-12 col-lg-8">
    		<div id="main" class="site-main" role="main">
    
    		<?php
    		while ( have_posts() ) : the_post();
    
    			get_template_part( 'template-parts/content-plan');
    
    			    the_post_navigation();
    
    			// If comments are open or we have at least one comment, load up the comment template.
    			if ( comments_open() || get_comments_number() ) :
    				comments_template();
    			endif;
    
    		endwhile; // End of the loop.
    		?>
    
    		</div><!-- #main -->
    	</section><!-- #primary -->
    
    <?php
    
    get_footer();