Support

Account

Home Forums General Issues Display Post Title From Select Choice Loop

Unread

Display Post Title From Select Choice Loop

  • I have custom post type (CPT) and the name is Programs.

    Inside the post type admin, I only give the title input and ACF “Select” Field Type.

    I only know how to display post title and list the ACF input field. But I want it to be reverse.

    The Select Field type as title, and the post title as the content.

    For example, I want the frontend to be like this:

    Information Technology (*as the select field in ACF)
    1.2. Information Technology is lorem ipsum dolor sit amet (* as the program description, I insert it into plugin).

    1.3. Website Development, Application Development, Artificial Intelligence (AI) (* this is the post title I insert in admin)

    My code had reached to display the select field type, but I’m stuck at displaying the post title.

    static function displayAllProgram(){
    
            $allProgram = new WP_QUERY(array(
                'post_type' => 'programs',
                'post_status' => 'publish',
                'orderby' => 'post_date',
                'order' => 'ASC',
                'posts_per_page' => -1
            ));
    
            if($allProgram->have_posts()){
    
                while($allProgram->have_posts()){
                    $allProgram->the_post();
    
                    $query_id = get_the_ID();
    
                    $post_object01 = get_field_object('field_62f4711a6e9e7');
                    if($post_object01){
    
                        $object_id = $post_object01->ID;
    
                        echo get_the_title($object_id);
                
                    }
                   
    
                }
    
             
    
                $field = get_field_object('study_programs');
            
    
                if( $field ){
                    foreach( $field['choices'] as $key => $value ){
                            ?>
                            <details>
                                <summary>
                                    <h2><?php echo $value; ?></h2>
                                </summary>
                                <p><?php edu003_displayProgramsCPT::program_description($value); ?></p>
                                
                            </details>
                            <?php
                    }
                }
    
            }
            
        }

    Any help is much appreciated, Thank You in Advance.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.