-
-
Save kirstenkeister/1895369 to your computer and use it in GitHub Desktop.
<?php | |
global $project_mb; | |
$project_mb->the_meta(); | |
$i = 0; | |
while($project_mb->have_fields('links') || $project_mb->have_fields('paststaff') ) { | |
if($i == 0) | |
{ ?> | |
<div id="info-staff" class="column left"> | |
<h2 class="column-title">Participating MITH Staff</h2> | |
<ul> | |
<?php } // endif | |
$staffname = $project_mb->get_the_value('projectstaff'); | |
$paststaffname = $project_mb->get_the_value('past-projectstaff'); ?> | |
<li><a href="<?php echo get_permalink($staffname); ?>" class="c-staff-link"><?php echo get_the_title($staffname); ?></a></li> | |
<li><a href="<?php echo get_permalink($paststaffname); ?>" class="p-staff-link"><?php echo get_the_title($paststaffname); ?></a></li> | |
<?php $i++; } // endwhile | |
if ($i > 0 ) { ?> | |
</ul> | |
</div> | |
<?php } // endif ?> | |
<!-- /project-staff --> |
Yeah, I generally try to do the open/close thing unless it's misbehaving. Sometimes I've had the information not show up properly when I do it with regular HTML, but it's probably fixable without echoing if I kept at it. Regardless, this is a good call and I will try to make open/close php tags standard unless absolutely necessary.
Did you already use the the_field() command to switch fields inside of a while loop? Looking at the WP_Alchemy website, it seems that they want you to set it up so that you pull the data once (do the while $project->have_fields() one time) then switch between data fields by either the_field or the_value calls.
If that isn't working, what I would suggest is that we take a look at your data model and see if it's not satisfying what you're asking it. Sometimes the issue with my stuff is that I design the data for one purpose, then find that I query for something totally different and have to go back and re-design the database. It's painful, but pays off in the long run.
This isn't a solution, just a best practices suggestion. In Wordpress, you want to avoid using the 'echo' function to add HTML. Instead, close out your PHP and then use plain HTML. If you need to insert variables, do so by opening and closing the PHP inside of the tags at the proper areas. As an example, this is how I'd write lines 5 - 9 of project-staff:
have_fields('links') ) { // loop through current staff $staffname = $project_mb->get_the_value('projectstaff'); ?>It looks crazy but it works and goes more with what you normally see in Wordpress. Sometimes, wordpress even omits HTML that you write in echo statements.