Displaying Posts Using a Custom Select Query
-
Hey there, I’m using this code to display only the last article that has not the custom field «featured» empty.
Yeah, I’m trying to code something to make a featured section.<?php global $wpdb; global $post; $querystr = " SELECT wposts.* FROM $wpdb->posts wposts LEFT JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id LEFT JOIN $wpdb->term_relationships ON (wposts.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 wpostmeta.meta_key != '' ORDER BY wpostmeta.meta_value ASC LIMIT 1"; echo $querystr[id]; ?>I think that there’s something wrong on the echo part, cause im not getting any sintax error. Could you give me a hand?
Thank you
The topic ‘Displaying Posts Using a Custom Select Query’ is closed to new replies.