Avatar of glepiza
glepiza
 asked on

Custom fields and excerpts

Dear experts,

Do you know how can I add custom fields to the post excerpts? I created a custom post type named places and wanted to add two custom fields named first_name and address. I would like to add to the excerpt those two custom fields instead of the usual short paragraph.
The way I am pulling my custom post type is as follows:

<?php
/*
 * Template Name: Places to go
 */



// Replace the loop.
remove_action(  'genesis_loop',   'genesis_do_loop' );
add_action( 'genesis_loop',   'places_custom_loop' );

genesis();

function places_custom_loop() {
 
            echo '<h1 class="entry-title">' . get_the_title() . '</h1>';
            the_content();
            //WP Query Start
            $per_page = 3;
            $places_args = array(
                'post_type' => 'places',
                'posts_per_page' => $per_page,
                                'paged' => get_query_var( 'paged' )
            );
            $places = genesis_custom_loop( $places_args );
}
 ?>

In the Advance Custom Fields plugin docs says that I have to echo out the custom fields like this : <?php the_field('first_name') ?>; But honestly I have no idea how to use it in the code above.

Could someone please help me?

Thanks,

Janeth
WordPressContent ManagementWeb-Based CMS

Avatar of undefined
Last Comment
glepiza

8/22/2022 - Mon
SOLUTION
Jason C. Levine

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
glepiza

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
glepiza

ASKER
Anyone?
Jason C. Levine

Pagination is a different question. You should close this down and open a new question dealing with that.
glepiza

ASKER
The answer provided by the experts did not work but it gave me an idea how to place the code on my excerpt. So after a long reading I ended up adding the code to the excerpt as I posted on the answers and it did work. Thanks!!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23