• Resolved joycegrace

    (@joycegrace)


    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="%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>';
    }
Viewing 1 replies (of 1 total)
  • Plugin Support ACF Support

    (@acfsupport)

    Hi @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 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.