Newbie Autodidact Question: When I use custom field key/value in loop to to filter output to a sidebar list, there is a long delay between posting the custom fielded page and its appearance on the blog. Why is this ?
Here's a snippet of what I'm doing - whether it's proper or not I don't know... I'm sure the switch code is redundant...
<?php
$querystr = "
SELECT DISTINCT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'Library'
AND wposts.post_type = 'page'
AND wposts.post_status = 'publish'
AND wposts.post_date < NOW()
AND ( wpostmeta.meta_value = 'Biography'
OR wpostmeta.meta_value = 'Eulogy'
OR wpostmeta.meta_value = 'History'
OR wpostmeta.meta_value = 'Maps'
OR wpostmeta.meta_value = 'Policy'
OR wpostmeta.meta_value = 'Reports' )
ORDER BY wpostmeta.meta_value,wposts.post_title
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
/* set up php vars to control sidebar library display features - e.g. whether there are maps, reports, euologies, histories etc... */
$Library_Categories_Array =
array("BIOGRAPHY"=>FALSE, "EULOGY"=>FALSE, "HISTORY"=>FALSE, "MAPS"=>FALSE, "POLICY"=>FALSE, "REPORTS"=>FALSE);
?>
<?php if ($pageposts): ?>
<ul> <!-- need to be at ul ul li a level for Library section heads printouts-->
<?php foreach ($pageposts as $post): ?>
<?php
setup_postdata($post);
$custom_arr = get_post_custom();
$Library_Category_Type = $custom_arr["Library"][0];
switch ($Library_Category_Type) {
case "Biography":
if ($Library_Category_Array["BIOGRAPHY"][0] == FALSE) {
$Library_Category_Array["BIOGRAPHY"][0] = TRUE;
echo "<li><a href=\"http://www.ourrumpus.com/the-library/\">Biography</a></li>";
break;
} else {
break;
}
case "History":
if ($Library_Category_Array["HISTORY"][0] == FALSE) {
$Library_Category_Array["HISTORY"][0] = TRUE;
echo "<li><a href=\"http://www.ourrumpus.com/the-library/\">History</a></li>";
break;
} else {
break;
}
case "Eulogy":
if ($Library_Category_Array["EULOGY"][0] == FALSE) {
$Library_Category_Array["EULOGY"][0] = TRUE;
echo "<li><a href=\"http://www.ourrumpus.com/the-library/\">Eulogy</a></li>";
break;
} else {
break;
}
case "Maps":
if ($Library_Category_Array["MAPS"][0] == FALSE) {
$Library_Category_Array["MAPS"][0] = TRUE;
echo "<li><a href=\"http://www.ourrumpus.com/the-library/\">Maps</a></li>";
break;
} else {
break;
}
case "Policy":
if ($Library_Category_Array["POLICY"][0] == FALSE) {
$Library_Category_Array["POLICY"][0] = TRUE;
echo "<li><a href=\"http://www.ourrumpus.com/the-library/\">Policy</a></li>";
break;
} else {
break;
}
case "Reports":
if ($Library_Category_Array["REPORTS"][0] == FALSE) {
$Library_Category_Array["REPORTS"][0] = TRUE;
echo "<li><a href=\"http://www.ourrumpus.com/the-library/\">Reports</a></li>";
break;
} else {
break;
}
default:
break;
}
?>
<ul><li ><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li></ul>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Thanks in advance for any clues/tips/criticismscode
Bob