Home Forums General Issues Query adding an extra row in table


Query adding an extra row in table

  • I converted the single custom field example from the following link ( to work for my website, and at first it worked fine, but is now not. I have it set up to do the following: find all entries that meet a certain criteria, display each of those entries with other assorted field in a table row. It works, technically, but all of a sudden, it started adding an extra row at the very top, with just one field filled in. You can view this happening over at . What I have happening, is this page calls for a php file that has the code. The weirdest part of this is that the piece at the bottom of this page ( uses an almost identical piece of code, but displays properly. Here is what I have being done for reference. Let me know if you have any other questions, and thanks ahead of time for help!

    $name = get_field('series_title');
    // args
    $args = array(
    	'numberposts'	=> -1,
    	'post_type'		=> 'page',
    	'meta_key'		=> 'series_title',
    	'meta_value'	=> $name,
    	'order'			=> 'ASC'
    // query
    $the_query = new WP_Query( $args );
    <?php if( $the_query->have_posts() ): ?>
    <table class="SeriesTable cols-8 table-hover">
                <th class="SeriesField SeriesFieldCounter"></th>
                <th class="SeriesField SeriesFieldNothing"></th>
                <th class="SeriesField SeriesFieldSeries" scope="col">Series</th>
                <th class="SeriesField SeriesFieldTitle" scope="col">Title</th>
                <th class="SeriesField SeriesFieldSpeaker" scope="col">Speaker</th>
                <th class="SeriesField SeriesFieldDate" scope="col">Date</th>
                <th class="SeriesField SeriesFieldReference" scope="col">Bible Reference</th>
                <th class="SeriesField SeriesFieldSoundcloud" scope="col">Audio</th>
    	<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
    			<td class="SeriesField SeriesFieldCounter"></td>
    			<td class="SeriesField SeriesFieldNothing">
                	<a href="<?php the_field('short_title'); ?>/"><i class="fa fa-play-circle"></i></a>
            	<td class="SeriesField SeriesFieldSeries">
            		<a href="<?php the_field('series_short_title'); ?>/"><?php the_field('series_title'); ?></a>
    			<td class="SeriesField SeriesFieldTitle">
    				<a href="<?php the_field('short_title'); ?>/"><?php the_field('title'); ?></a>
    			<td class="SeriesField SeriesFieldSpeaker">
    				<a href="<?php echo str_replace(' ','-',get_field('speaker_name')); ?>/"><?php the_field('speaker_title'); echo ' ';the_field('speaker_name'); ?></a>
    			<td class="SeriesField SeriesFieldDate">
    				<?php the_field('date'); ?>
                <td class="SeriesField SeriesFieldReference">
                	<a href="<?php the_field('bible_reference_book'); ?>%20<?php the_field('bible_reference_chapter_verse'); ?>&version=KJV" target="_new"><?php the_field('bible_reference_book'); ?> <?php the_field('bible_reference_chapter_verse'); ?></a>
                <td class="SeriesField SeriesFieldSoundcloud">
                	<iframe width="100%" height="100" scrolling="no" frameborder="no" src="<?php the_field('soundcloud'); ?>&show_artwork=false&auto_play=false&show_playcount=false&color=606060&sharing=false"></iframe>
    	<?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_query();	 // Restore global post data stomped by the_post(). ?>
  • Hi @calebsurface

    It’s possible that you have an empty page with ‘series_title’ field set on that page. You can check it by using this code:

    $the_posts = get_posts($args);
    echo "<pre>";
    echo "</pre>";

    That code will show the list of pages and its ID. Then you can check from the backend if you have that page or not.

    I hope this helps.

  • Well this helped me solve the problem by thinking about it. Basically what was happening is this: I have two separate ACF groups; sermons and series. Every sermon falls into a series, so I had “series_title” as a field name in the sermons field group. In the series field group, I also had “series_title” because, obviously, the series needs a title. I wasn’t thinking about how my code pulled from every group, anything that had “series_title”, so that top row was the entry for the series “Restart”, and thus had none of the other fields filled out because that entry didn’t have those fields at all. Does that make sense? I fixed it by changed the sermons field group to have “series_name” for the field instead of “series_title”.

  • Hi @calebsurface

    Yeah, you need to have unique custom field names for each post, page, taxonomy, etc as ACF heavily depends on it. If you have the same field name, ACF will have a hard time to get the right value for you.

    I hope this makes sense 🙂

  • Yes it does! It’s all working correctly now, so I’m glad I got it worked out. It was one of those problems where I knew that would happen in the back of my head, it just didn’t click. Thanks for your help!

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

The topic ‘Query adding an extra row in table’ is closed to new replies.