Showing posts side by side
-
I am trying to set up a wordpress site that will show two posts side by side as a “point/counterpoint”. The main page was easy:
https://xsaidysaid.sohigian.com
I simply used categories to position the latest post on each side of the page.
But I want single post pages to also show up with the two articles with the same topic to be paired together. My first thought was to use meta key values, but I am having difficulty with the query used to make them show up in 2.7. I will describe further, but I am wondering if there is another approach that would make more sense as well.
My query code looks like this:
<?php $querystr = " SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE $wpdb->term_taxonomy.term_id = 114 AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->posts.post_status = 'publish' AND $wpdb->postmeta.meta_key = 'Topic' "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?>
I am looking for all the posts in category 114 which have a meta_key of Topic. Eventually I also want to get the value of that meta key, but I can’t even get this to return any results.
Again I am open to other suggestions for approaches.
- The topic ‘Showing posts side by side’ is closed to new replies.