Support

Account

Forum Replies Created

  • Just trying to show the taxonomy category name that is selected in the custom post entry.

  • 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();
  • Thanks again.

    Tried the 3 ways.. Doesn’t work. Echo nothing. πŸ™

    Here is code i tried for the first option (single object). I also attached a screenshot for the fiel settings in ACF.

    <?php
    $term = get_field(‘plan_type’);
    if( $term ): ?>
    <h2><?php echo esc_html( $term->name ); ?></h2>
    <p><?php echo esc_html( $term->description ); ?></p>
    <?php endif; ?>

  • <?php the_field(‘plan_type’, ‘term_’.$term_id); ?> and <?php the_field(‘plan_type’, $term); ?> dont generate a content.

    I think I don’t get it. Sorry πŸ˜‰

    Do I have to replace $term or $term_id by something else?

    To make it clearer, plan_type is a field in ACF (a taxonomy field – i choosed category). Th field is inthe group field for the CPT. So ca category have to be choosed (different for every post).

    I am trying to make the unique post (single post) template, showing the category choosed on the post unique page.

  • Thanks again!!

    If I choose option to make the number field conditional based on the radio field, and I choose defaut value of 10 000, will that specific value be saved in database if unlimited is choosen (and number field hidden)?

  • Great answer! Thanks πŸ‘

    May I ask what you would do about the frontend, to show unlimited instead of 10000 in WPDatables?

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