WordPress 3 Custom Fields - &ugh!

I am building a real estate About Us / Agent page. The idea is to list each Agent on the About Us page by pulling data from the child Agent page and its Cutom Fields.

the Agent Custom fields are: agent_name agent_phone agent_email agent_website …yada yada yada
the About Us Custom field is: agentpage (value: agent|78,agent|82,agent|90 (where 78 is the Agent page number from the WP3 URL))

I get the right amount of agents returned and no custom field data.


	<?php
		
		$categoriesCF = get_post_meta($post->ID, "agentpage", true); 	
		$allCategories = explode(",", $categoriesCF);

		foreach ($allCategories as $category) {
			$pieces = explode("|", $category);
					
			$link = get_permalink($pieces[1]);
			
			/* query_posts("posts_per_page=-1&post_type=page&post_parent=$pieces[1]"); */
			
		echo "<table class='agent-info' width='100%' border='0' cellspacing='0' cellpadding='0'><tr>";
		echo "<td width='200'  align='left' valign='top'>";
		echo "<img src=" . get_post_meta($post->ID, 'agent_photo_190', true) . " />";
		echo "<td  align='left' valign='top'>";
		echo "<div class='agent-info-box'>";
		echo "<h3><a href='$link'>" . $link . "</a></h3>";
		echo "<body><?php echo get_post_meta($post->ID, 'agent_bio', true); ?></body><br />";
		echo "<p style='padding-left: 30px;'>";
		echo "<body>phone:&nbsp;<?php echo get_post_meta($post->ID, 'agent_phone', true); ?></body><br />";
		echo "<body>fax:&nbsp;<?php echo get_post_meta($post->ID, 'agent_fax', true); ?></body><br />";
		echo "<body>email:&nbsp;<?php echo get_post_meta($post->ID, 'agent_email', true); ?></body><br />";
		echo "<body>website:&nbsp;<a href='<?php echo esc_url( __( 'http://wordpress.org/' ) ); ?>' ><?php echo get_post_meta($post->ID, 'agent_website', true); ?></a></body><br />";
		echo "</p></ul></div</td</tr></table>";		
		echo "<br /><hr style='width:100%;' /><br />";	

			while (have_posts()) : the_post(); ?>

			<?php endwhile; wp_reset_query();
		};
	?>

I have not failed, I have found 10,000 ways that do not work - T Edison.

any clues?
greg

Okay… So I tried 147 more times, I did a whole new rewrite; and I got someting that works for me, but it still has issues.

I took-out

the About Us Custom field is: agentpage (value: agent|78,agent|82,agent|90 (where 78 is the Agent page number from the WP3 URL))

The QUERY POST now tries to return all of the Pages (including the Newsletter page, the Featured Listings page…) in the coded HTML format below, but since I only have eleven Agents, I was able to limit the posts_per_page to 11 (I call that a “fix”, but not a “solution”).
??? Any ideas on how to set the posts_per_page to -1 (show all) without returning the kitchen sink - I want just those pages that are Agent Pages with the Custom Fields ???

Also, one other issue, I lost control of the Agent order, it is now reverse.



	<?php
	
		$categoriesCF = get_post_meta($post->ID, "agentpage", true);
		$allCategories = explode(",", $categoriesCF);

		foreach ($allCategories as $category) {
			$pieces = explode("|", $category);
			$link = get_permalink($pieces[1]);

			[B]query_posts("posts_per_page=11&post_type=page&post_parent=$pieces[1]");[/B]

			while (have_posts()) : the_post(); ?>

			<table class="agent-info" width="100%" border="0" cellspacing="0" cellpadding="0">
			  <tr>
			    <td width="200"  align="left" valign="top">
					<img src='<?php echo get_post_meta($post->ID, 'agent_photo_190', true); ?>' /></td>
			    <td  align="left" valign="top">
					<div class="agent-info-box">
					<h3><?php echo get_post_meta($post->ID, 'agent_name', true); ?></h3>
					<body><?php echo get_post_meta($post->ID, 'agent_bio', true); ?></body><br />
				<p style="padding-left: 30px;">
					<body>phone:&nbsp;<?php echo get_post_meta($post->ID, 'agent_phone', true); ?></body><br />
			        <body>fax:&nbsp;<?php echo get_post_meta($post->ID, 'agent_fax', true); ?></body><br />
			        <body>email:&nbsp;<a href='mailto:<?php echo get_post_meta($post->ID, 'agent_email', true); ?>' /><?php echo get_post_meta($post->ID, 'agent_email', true); ?></a></body><br />
			        <body>website:&nbsp;<a href='<?php echo get_post_meta($post->ID, 'agent_website', true); ?>' /><?php echo get_post_meta($post->ID, 'agent_website', true); ?></a> </body><br />
				</p>
				</div>
			    </td>
			  </tr>
			</table>
			
			<br /><hr style='width:100%;' /><br />
			
			<?php endwhile; wp_reset_query();
			
		};
	?>