I am creating a Wordpress theme for any client and it is unlike every other theme I have built before for the reason that the home page is an accumulation of posts spread across multiple different containers and designs. It's designed to feel and look just like a magazine for the reason that, at the outset of every month, 9 different posts are released concurrently that every belong to another category. And most of the posts are styled in a different way, I am not able to make use of the standard Loop:

<?php if(has_posts()) : while(has_posts)) : the_post(); ?>
// do stuff
<?php endwhile; endif; ?>

First, I'll let you know that I am attempting to solve the issue, then describe the problems I am getting.

Towards the top of index.php, I've the next PHP code:

$slugPostMap = array();
$slugs = array(
    'art', 'big-idea', 'books', 'educators', 'film',
    'ministry-update', 'music', 'parents', 'students',
);
$args = array(
    'limitposts'    => 1,
    'order'         => 'date' 
);

foreach($slugs as $slug){
    $args['category_name'] = $slug;
    $post = get_posts($args);
    $slugPostMap[$slug] = $post;
}

The $slugs array is an accumulation of each one of the category slugs that I'll have to query with - all these may have one publish to become displayed. The concept is will be able to loop over this array and, utilizing an otherwise-fixed group of query parameters ($args), retrieve the only newest publish for all these slugs. As I am looping within the slug array, I am storing the query lead to an associative array ($slugPostMap) in which the category slug "indicatesInch the particular publish.

Afterwards in your body from the page, I am getting the needed publish from $slugPostMap while using category slug index. Here's a good example:

<?php  
foreach($slugPostMap['ministry-update'] as $p): 
    setup_postdata($p); 
?>
<a class="homepageVideoPostTitle" href="<?php the_permalink(); ?>"><?php the_date('F Y','','',true); ?></a>
<div class="homepageVideoPostSubtitle">
    <?php the_title();  ?>
</div> <!-- end homepageVideoPostSubtitle -->
<div class="homepageVideoPostContent">
    <?php the_excerpt(); ?>
</div>
<?php endforeach; ?>

The main reason I am utilizing a foreach loop at the start happens because, when i comprehend it, some of the core Wordpress template tags (the_title(), the_permalink(), etc.) are just available inside the Loop. Because I am calling setup_postdata() by hand here (that is known as behind the curtain throughout The Loop), I am also while using foreach to limit the scope of whatever weirdo voodoo occurs when I call setup_postdata().

Typically, this works. Within the above example, the outcomes of calling the_excerpt() appear not surprisingly. However, another template tags aren't coming back any values (the_permalink() and the_title(), particularly). I am not receiving any errors and also the page loads fine after i do this in a genuine live Wordpress install.

I am presuming the issue is based on my lack of knowledge of methods to correctly bypass The Loop in cases like this, but the truth that there isn't any errors or other clue regarding the problem has introduced me here.

This really is Wordpress 3. running on some flavor of Linux. I have got a number of other Wordpress installs running about this box without problem and I am able to utilize this same Wordpress instance using the default theme with no problem.

Appreciate your time and effort - sorry for that novel. Please tell me basically there's any relevant particulars I have overlooked.

These template functions use: global $post; to gain access to the publish information.

Rather than this:

foreach($slugPostMap['ministry-update'] as $p):

you need to have the ability to simply employ $publish because the child variable:

foreach($slugPostMap['ministry-update'] as $post):

As with your situation, I'm not sure what strange voodoo happens either, but let's say you transformed your theme code to make use of functions that actually work outdoors the loop. The get_permalink($id) and single_post_title() must do the thing you need.