Support

Account

Home Forums General Issues Query CPT to display fields in single post

Unread

Query CPT to display fields in single post

  • I’m trying to display fields from a CPT in a single blog post. The idea is to display the “best” of a category of products. I’ve tried following this documentation: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    The code, however, displays the title of the single post, not the CPT I’m trying to loop through.

    I’ve tried many variations of the following code:

    <?php
    /*
     * Template Name: Cash Management Account Listing
     * Template Post Type: post
     */
     
    add_action ( 'genesis_before_entry_content', 'cma_data');
    
    function cma_data(){
    	
    	$posts = get_posts(array(
    		'posts_per_page'	=> -1,
    		'post_type'			=> 'banking',
    		'post_status' 		=> array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'),
    		'meta_key'			=> 'bank_type',
    		'meta_value'		=> 'cma'
    ));
    	
    if( $posts ):
    			
    	foreach( $posts as $post ): 
    		
    		setup_postdata( $post );
    		
    			the_title();
    	
    	endforeach;
    		
    	wp_reset_postdata();
    
    endif;
    	
    }
    
      genesis();
    
     ?>

    Any guidance would be appreciated.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.