Support

Account

Home Forums Add-ons Repeater Field Styling subfields

Solved

Styling subfields

  • I’d like to apply styling to the individual sub-fields. Example H3 on the Position for each repeater, while also ensuring that each row stays seperate from the next. I’ve done that now with just a p tag, but I would like also to know if there’s a better way. This is being added to my functions file.

    //* Add Current Officer Meta to Current Officers Page
    add_action( 'genesis_entry_header', 'ogs_current_officer', 12 );
    function ogs_current_officer($post_meta) {
    	if ( is_page ( 'officers-trustees' ) ) {
    	// check if the repeater field has rows of data
    if( have_rows('officer_or_trustee') ):
     	echo '<p>';
     	// loop through the rows of data
        while ( have_rows('officer_or_trustee') ) : the_row();
    
            // display a sub field value
    		the_sub_field('position');
    		the_sub_field('name');
    		the_sub_field('term_years');
    		the_sub_field('co_org');
    		the_sub_field('phone');
    	echo '</p>';
        endwhile;
     
    else :
     
        // no rows found
     
    endif;
    }}
  • I figured it out. My solution is below if anyone else wants to see it.

    //* Add Past Officer Group Meta to Past Officers Page
    add_action( 'genesis_entry_header', 'ogs_past_officers', 12 );
    function ogs_past_officers($post_meta) {
    	if ( is_page ( 'past-officers' ) ) {
    	if( have_rows('add_past_officer_group') ):
     
    	
     
    	while( have_rows('add_past_officer_group') ): the_row(); 
     
    		// vars
    		$term_years = get_sub_field('term_years');
    		$po_president = get_sub_field('po_president');
    		$po_vp = get_sub_field('po_vp');
    		$po_vp_1 = get_sub_field('po_vp_1');
    		$po_vp_2 = get_sub_field('po_vp_2');
    		$po_secretary = get_sub_field('po_secretary');
    		$po_treasurer = get_sub_field('po_treasurer');
     echo '<p>';
    			if( $term_years): 
    				echo '<b>Term Years:</b> ' . get_sub_field('term_years'). '';
    			endif;
    			if( $po_president ):
    				echo '<b>President:</b> ' . get_sub_field('po_president'). '';
    			endif; 
    			if( $po_vp ):
    				echo '<b>Vice President:</b> ' . get_sub_field('po_vp'). '';
    			endif; 
    			if( $po_vp_1 ):
    				echo '<b>1st Vice President:</b> ' . get_sub_field('po_vp_1'). '';
    			endif; 
    			if( $po_vp_2 ):
    				echo '<b>2nd Vice President:</b> ' . get_sub_field('po_vp_2'). '';
    			endif; 
    			if( $po_secretary ):
    				echo '<b>Secretary:</b> ' . get_sub_field('po_secretary'). '';
    			endif; 
    			if( $po_treasurer ):
    				echo '<b>Treasurer:</b> ' . get_sub_field('po_treasurer'). '';
    			endif; 
      echo '</p>';
    		    echo $content; 
     
     
    	endwhile; 
     
     
    endif;
    }}
  • It’s amazing and working , how do you that?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.