Title: Wrap fields in a function with a div
Last modified: May 7, 2023

---

# Wrap fields in a function with a div

 *  Resolved [joycegrace](https://wordpress.org/support/users/joycegrace/)
 * (@joycegrace)
 * [3 years ago](https://wordpress.org/support/topic/wrap-fields-in-a-function-with-a-div/)
 * Hello, I am using the template instructed here: [https://sridharkatakam.com/custom-post-type-archive-with-custom-fields-in-genesis/](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](https://cloudup.com/cnpqOnEnX1f)
 * ![](https://i0.wp.com/cldup.com/fSOT42dULv-2000x2000.png?resize=2000%2C2000&ssl
   =1)
 * The code I’m working with:
 *     ```wp-block-code
       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="%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:
 *     ```wp-block-code
       // 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>';
       }
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Support [ACF Support](https://wordpress.org/support/users/acfsupport/)
 * (@acfsupport)
 * [3 years ago](https://wordpress.org/support/topic/wrap-fields-in-a-function-with-a-div/#post-16717917)
 * Hi [@joycegrace](https://wordpress.org/support/users/joycegrace/)
 * ACF Support Team here. This forum is generally used by ACF users to help each
   other out. 
 * However, we would love to continue investigating and troubleshooting this issue,
   please can you create a ticket using our [​support form](https://www.advancedcustomfields.com/contact/)
   and we can look into it further.

Viewing 1 replies (of 1 total)

The topic ‘Wrap fields in a function with a div’ is closed to new replies.

 * ![](https://ps.w.org/advanced-custom-fields/assets/icon.svg?rev=3207824)
 * [Advanced Custom Fields (ACF®)](https://wordpress.org/plugins/advanced-custom-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-custom-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-custom-fields/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)

 * 1 reply
 * 2 participants
 * Last reply from: [ACF Support](https://wordpress.org/support/users/acfsupport/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/wrap-fields-in-a-function-with-a-div/#post-16717917)
 * Status: resolved