Support

Account

Home Forums Front-end Issues Field not outputting on category page

Helping

Field not outputting on category page

  • HI –
    I have added a text field with a field name ‘lorem_ipsum’ to add an extra field to each category.

    I have set show this field to:

    Taxonomy is equal to Category.

    The field shows on the category page in the editor ok.

    I have added the field to the archive page but it is not outputting. Is there something else I need to do on category pages?

    
    <?php
    /**
     * The template for displaying archive pages
     *
     * @link https://codex.wordpress.org/Template_Hierarchy
     *
     * @package cvb
     */
    get_header(); ?>
    	<div id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
    		<?php
    		if ( have_posts() ) :?>
    			<header class="page-header">
    				<?php
    					the_archive_title( '<h1 class="page-title">this is the archive page', '</h1>' );
    					the_archive_description( '<div class="archive-description">', '</div>' );
    				?>
    				<p><?php the_field('lorem_ipsum') ?></p>
    			</header>
    			<?php
    			while ( have_posts() ) : the_post();
    				/*
    					* Include the Post-Format-specific template for the content.
    					* If you want to override this in a child theme, then include a file
    					* called content-___.php (where ___ is the Post Format name) and that will be used instead.
    					*/
    				get_template_part( 'template-parts/content', get_post_format() );
    			endwhile;
    		else :
    			get_template_part( 'template-parts/content', 'none' );
    		endif; ?>
    		</main><
    	</div>
    <?php
    get_footer();
    
  • 
    $queried_object = get_queried_object();
    the_field('lorem_ipsum', $queried_object)
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.