Page Template: How to populate with crieteria in custom fields
-
Hi guys,
Dont know if anyone can help I am trying to populate a page with posts where a custom field “AssocBlogID” has a value = current page ID.Effectivly it is a page for a user to contain his own posts only. If there is a better way of doing it that fits with a Suffusion child theme I am all ears (well eyes – you know what I mean) My starting point was to copy and modify posts.php (a page of posts) so that I didnt break the theme. Obviously the following code is an extract.
I am getting the correct value into $pageID and I have created one post to test the method, but the query is populating the page with a different post, that does not have AssocBlogID set. Can anybody point me to where I am going wrong – cheers.
$pageID = $post->ID; $args = array( 'meta_key' => 'AssocBlogID', 'meta_value' => $pageID, 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged, ); //********************************End of mod $temp = $wp_query; // assign original query to temp variable for later use //$wp_query = null; // Resetting this to null was causing a PHP Notice to pop up $wp_query = new WP_Query($args);
- The topic ‘Page Template: How to populate with crieteria in custom fields’ is closed to new replies.