Query Help
-
Hi,
I am just looking for some help on a query. So far I have it pulling the correct posts, based on a meta field / value. But I am having problems doing the post data setup. I received some good advice from some helpful posters in another thread, tried out somethings in the wpdb example file, and got some help from the google group for magic fields, but I’m stumped, and was wondering if anyone has a suggestion.
Here’s the code:
<?php // go to the database and get the a certian meta key. Find a value similar to X in the serialized array $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key = 'grade-type' AND meta_value like '%Post Secondary%'"; $rows = $wpdb->get_results($query); foreach($rows as $row){ setup_postdata($row); // Pull remaining post data from correct database $curpost = $row->post_id; $curquery = "SELECT * FROM $wpdb->posts WHERE ID = '$curpost'"; $currow = $wpdb->get_results($curquery); setup_postdata($currow); echo "the post title:" . $currow->post_title; print_r($currow); //just for testing } ?>
And here’s the link to the beta site (please ignore any oddness, its still in the works)
https://work.nadinelessio.com/firstsecond/build/teaching-resources/making-comics/
Thanks!
Nadine
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Query Help’ is closed to new replies.