Home Forums General Issues Repeater Fields in Table Data


Repeater Fields in Table Data

  • Hi Everyone,

    I am struggling with what I think can be done (I very easily could be wrong), I am working on a page which will be a list of information for my client to be able to use as a reference guide (they are currently using a spreadsheet which multiple people access and issues are being encountered due to locking).

    So I thought I would be a CPT to hold the information they are using and thus no more spreadsheet being maintained and no more locking issues.

    The data is pretty straight forward, it contains Fire Department Name, an Ordinance and other data pertaining to the department and any ordinances tied to the fire department.

    Some department cover multiple townships, so there could be multiple ordinances listed for a department, I would like to have the ordinances assigned to a department listed below the Fire Department, the layout I am trying to obtain is as follows:

    Station Name Notes Direct Submit Direct Individual Update
    01-001 Gettysburg AFA Only Yes No Edit
    01-009 York Springs Yes Yes Edit
    York Springs Brough Ordinance 01-2009 View / Email
    York Springs Township Ordinance 02-2009 View / Email
    01-010 City of York Yes No Edit

    The indented items below York Springs are fields from a repeater field with two subfields 1) Ordinance Info and Ordinance URL). The URL is used to build both the View hyperlink (link to Dropbox link so a user can View the Ordinance and the Email is a link to the same Dropbox link to allow the user to email the link to someone who needs it, the email link will open email client and have some basic text already filled in)

    The issue I am having is that I cannot get the data from the repeater field to appear, the code I am using is listed below. I am not sure if I can do what is listed in my code, as I am trying to build a row in a table based on if it has the subfields for a record.

    I tried to say, if you have rows, then do this echo statement, else use the other echo statement (no data in the subfields), but have had no luck yet.

    I have commented out the “Notes” field in the second table echo intentionally so I know which table is being read at the time I am viewing the page (helps my own sanity at this time), the else table is always being built.

    I cannot provide a link to the site as I am developing locally, but if anyone needs to see the current process, you can view it at the following URL –

    After I built the page and started to add the View / Email option is when I found the issue with the multiple townships (initial specs didn’t include View / Email options available to users, but now they want it).

    Any tips//suggestions would be appreciated, I don’t logically see why it wouldn’t work unless I am missing some additional code.

    Can this even be done?

     * Template Name: Ordinance List Template
     * Description: Template used for generating a list of ordinances
    //* Force Full Widthe Content
    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
    //* Add custom body class
    add_filter( 'body_class', 'childthemeprefix_about_body_class' );
    function childthemeprefix_about_body_class( $classes ) {
    	$classes[] = 'ordinance-list';
    	return $classes;
    //* Remove Footer Widgets
    remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );
    add_action( 'genesis_entry_content', 'kk_query_ordinances');
    // prepare arguments
    function kk_query_ordinances () {
    // args
    $args = array(
    	'numberposts'	        => -1,
    	'post_type'		=> 'ordinances',
    	'orderby'		=> 'title',
    	'order'			=> 'ASC',
    	'nopaging' 		=> true, 
    // query
    $the_query = new WP_Query( $args );
    echo '<table>
    		<th width=30%><br/>Station Name</th>
    		<th width=45%><br/>Notes</th>
    		<th width=10%>Direct-<br/>Submit</th>
    		<th width=10%>Direct-<br/>Individual</th>
    		<th width=8%>Update<br/> Info</th>
    $ordinances = $the_query->get_posts();
     if (! empty ( $ordinances ) ) { 		
    	 foreach ( $ordinances as $ordinance) {
    		 $ordinance_data =  get_post( $ordinance->ID );
    		echo '<table class="ordinancetable">';
    		 if ( have_rows ( 'ordinance_resolution' ) ) :
    		 	while (have_rows( 'ordinance_resolution') ) :the_row();
    		 echo '<tr>'
    		 , '<td width = "30%">', $ordinance_data->post_title, '<br/>' . $ordinance_data->ordinance_info . ' ' . $ordinance_data->ordinance_url . '</td>'
    		 , '<td width = "45%">', $ordinance_data->notes, '</td>'
    		 , '<td width = "10%">', $ordinance_data->direct_submit, '</td>'
    		 , '<td width = "10%">', $ordinance_data->direct_individual, '</td>'
    		 , '<td width = "8%"> <a href="' , get_edit_post_link( $ordinance_data->ID ) ,'">Edit</a></td>'
    		 , '</tr>';
    				else :
    		echo '<tr>'
    		 , '<td width = "30%">', $ordinance_data->post_title, '</td>'
    		 // , '<td width = "45%">', $ordinance_data->notes, '</td>'
    		 , '<td width = "10%">', $ordinance_data->direct_submit, '</td>'
    		 , '<td width = "10%">', $ordinance_data->direct_individual, '</td>'
    		 , '<td width = "8%"> <a href="' , get_edit_post_link( $ordinance_data->ID ) ,'">Edit</a></td>'
    		 , '</tr>';
    	 } // End of Foreach loop
    	 echo '</table>';
     } // End of If ! Empty Statement
    } // End of kk_query_ordinances Function
  • [SOLVED]

    Worked with a person in my area who is more proficient in ACF than myself and he was able to help me out.

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

You must be logged in to reply to this topic.