Wrap fields in a function with a div

[ad_1]

Hello, I am using the template instructed here: https://sridharkatakam.com/custom-post-type-archive-with-custom-fields-in-genesis/

I need to wrap the custom fields in a div. Everything I’ve tried and googled is not working.

Can anyone help shed light on this? I would be so grateful. Or even a lead on where I need to go with this…

Here is a screenshot of what I’m trying to wrap: https://cloudup.com/cnpqOnEnX1f

The code I’m working with:

add_action( 'genesis_entry_content', 'sk_fields' );
/**
 * Shows the values of doctor profiles custom fields below the content.
 */
function sk_fields() {

   $doctor_title = get_post_meta( get_the_ID(), 'doctor_title', true );
   $doctor_specialty = get_post_meta( get_the_ID(), 'doctor_specialty', true );
   $doctor_hours = get_post_meta( get_the_ID(), 'doctor_hours', true );
 		
     if ( $doctor_title ) {
        echo '<h3 class="doctor-heading">Title</h3>';

        echo '<p class="doctor-text">' . get_field('doctor_title') .  '</p>';
		 
    }
    if ( $doctor_specialty ) {
        echo '<h3 class="doctor-heading">Specialty</h3>';

		echo '<p class="doctor-text">' . get_field('doctor_specialty') .  '</p>';
    }
	
		
		$loop = ''; // init
		
		$loop .= sprintf( '<a href="https://projectdmc.org/support/topic/wrap-fields-in-a-function-with-a-div/%s" class="more-link">%s</a>', get_permalink(), __( 'See bio', 'genesis' ) );

		printf($loop );

}


genesis();

Note that the following only works to wrap the entire content, including the photo, but I’m trying to wrap the fields WITHOUT the photo:

// Add custom opening div for post title
add_action( 'genesis_entry_content', 'sk_do_div_before', 7 );
function sk_do_div_before() {
	echo '<div class="doctor-fields">';
}
// Add custom closing div for post title
add_action( 'genesis_entry_content', 'sk_do_div_after' );
function sk_do_div_after() {
	echo '</div>';
}

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer