Im starting to delve deeper into Wordpress custom fields and wanting to replicate this page in Wordpress:http://www.clubsact.com.au/corporate/index.php
So my site is not tightly structured to a parent/child relationship, I have created a custom field \'Partner_Level\' and based on the partner level entered by the author the function will write out the Feature Image associated with the post and create my index page.
Though I cant even seem to get my query working within a function. If I follow the instructions on this page:http://css-tricks.com/snippets/wordpress/custom-loop-based-on-custom-fields/ writing straight to my template, all is good. So Im assuming I don\'t have something configured correctly, but at a lose as to what.
Functions.php
function the_partners($cpLevel) {
// This query grabs all fields with Metadata, matches
$querydetails = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = \'Partner_Level\'
AND wpostmeta.meta_value = \'$cpLevel\'
AND wposts.post_status = \'publish\'
AND wposts.post_type = \'page\'
ORDER BY wposts.post_date DESC
";
$pageposts = $wpdb->get_results($querydetails, OBJECT);
if ($pageposts) {
echo "Got em";
}
}
page_corp.php
if (have_posts()) : while (have_posts()) : the_post();
<h1><?php the_title(); ?></h1>
the_partners(\'Gold\');
endwhile; endif;
In the page, Im simply expecting "Got em" to be printed to the screen, though Im getting a blank.
Cheers,
Phil