Hi there,
I'm very new to WordPress but very impressed. However, I'm stuck on a problem.
I'm trying to build a custom page called services that collects information from post categories + custom fields, and generates a neat little table.
The following code (minus the template name) works just fine if I edit the index.php template:
http://blog.wearetheoriginals.co.uk/
But when I create a new page (not a new entry) and assign a template to it, with the code below. I get zip:
http://blog.wearetheoriginals.co.uk/?page_id=9
What am I doing wrong?
BTW I know the code is probably horrible, so be kind. ;)
<?php
/*
Template Name: services
*/
?>
<html>
<head>
<title>Services</title>
</head>
<body>
<?php
$clientArray = array();
$clientNameArray = array();
$blank = array('Client' =>'name', 'website' => 'no', 'logo' => 'no', 'stationery' => 'no');
if (have_posts()) :
while (have_posts()) : the_post();
echo 'foo';
$tempArray = $blank;
if (in_category(4)) :
$category =get_the_category();
$category = $category[0]->cat_name;
$clientName = get_post_meta($post->ID, 'client', true);
if(!array_search($clientName, $clientNameArray )){
array_push($clientNameArray, $clientName);
$tempArray['Client'] = $clientName;
$tempArray[$category] = 'yes';
array_push($clientArray, $tempArray);
}else{
for ($i =0; $i < count($clientArray); $i ++) {
if($clientArray[$i]['Client']==$clientName){
$clientArray[$i][$category]= 'yes';
}
}
};
endif;
endwhile;
endif;
print_r($clientArray);
?><table border='1'><?php
for ($j =0; $j < count($clientArray); $j ++) {
?><tr> <?php
foreach ($clientArray[$j] as $key => $value){
?><td><?php echo $value; ?></td><?php
}
?><tr /><?php
}?></table>
</body>
</html>