• Resolved rickschwein

    (@rickschwein)


    I am trying to build a custom page template for my church site to present links to podcasts and notes on series of sermons.

    By using tags in the posts and a custom field in the calling page, I am able to build an HTML table with fields for each sermon’s podcast and study notes. I use query_posts("tag=$tag&order=asc") to build the object list (where $tag is the value of the custom field of the calling page. The Loop does all the heavy lifting.

    My problem is that I cannot find a way to have the calling page display anything except the results of The Loop’s work. I want the page to display an image, then a summary/scope statement on the teaching series, and then the list/table of individual messages.

    Can someone please point me to a forum discussion or CODEX section to help me figure out what I’m doing wrong?

    Thanks!

    Here’s the guts of the template:

    <?php $this_id = get_the_ID();
    	the_content();  // this gets nothing!
    	$page_meta = get_post_meta($this_id, 'Series_Name');
    	$tag = $page_meta[0];
    	$posts = query_posts( "tag=$tag&order=asc" );
    ?>
    
    <?php include(TEMPLATEPATH."/breadcrumbwide.php");?>
    <table border=1 cellpadding=10>
    <tr><th>Part No.</th><th>Podcast link</th><th>Notes link</th></tr>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <tr>
    <td>
    	<?php
    		$post_title = get_the_title();
    		$regex = '/\d+$/';
    		preg_match($regex, $post_title, $matches);
    		$part = $matches[0];
    		echo $part;
    	?>
    </td>
    	<?php
    		$id = get_the_ID();
    		$meta_array = get_post_meta($id, 'Notes_ID');
    		$notes = $meta_array[0];
    		$metas = get_post_meta($id, '_podPressMedia');
    		$uri = $metas[0][0]['URI'];
    	?>
    <td><!-- call an MP3 player loaded with the podcast --></td>
    <td><?php if($notes > 0) {
    	printf("<a href='https://localhost/?p=%d', target='_new'>View the notes</s>", $notes);
    } else { echo "Notes unavailable"; } ?>
    </td>
    </tr>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    </table>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter rickschwein

    (@rickschwein)

    It looks like the solution to my problem is in this post.

    I’ll mark this as resolved when I know for sure …

    Thread Starter rickschwein

    (@rickschwein)

    Yep … that did it. The key:

    first instance of The Loop displays the page contents,
    then query to get the metadata to build the list of needed information to build my table.

    Of course, the solution was pretty simple.

    <?php
    	$this_id = get_the_ID();
    
    	if ( have_posts() ) : while ( have_posts() ) : the_post();
    		the_content();
    	endwhile; else: endif;
    
    	$page_meta = get_post_meta($this_id, 'Series_Name');
    	$tag = $page_meta[0];
    	$posts = query_posts( "tag=$tag&order=asc&posts_per_page=-1" );
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with page to list post information as a table’ is closed to new replies.