I wanted to display a list of posts, on a page, from a specific category number specified in a custom field on the page.
Any Ideas?
Thanks
Scott
I wanted to display a list of posts, on a page, from a specific category number specified in a custom field on the page.
Any Ideas?
Thanks
Scott
I do exactly that in my site here, and in several other pages. The category name is in a Custom Field named 'category-to-show'. The relevant code is:
<?php $this_cat=get_post_meta($post->ID,'category-to-show',TRUE);
if ($this_cat != "") {
$paged = get_query_var('paged');
$args = array( 'category_name' => $this_cat, 'paged' => $paged,);
query_posts($args);Thanks for the response...
Tried the code but it is giving me a syntax error. Please forgive as I am just learning php/wp...
Could you elaborate?
Thanks in advance!
That code is not meant to be used 'as is'. It must be adapted to your theme. Without access to the theme code, I cannot give more specific instructions.
Can you post the code for your page template in a pastebin and post the link to it here?
http://wordpress.pastebin.com/3Je37jmX
Trying to display the posts in the 'storepage' area
store_couponcat being the custom field
Thanks Again
Try adding the code as shown below just ahead of your if (have_posts()):
<?php query_posts(
array_merge($wp_query->query,
array('cat' => $store_couponcat))
); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>Tried that code, and its not displaying anything...
Here is my current code with the category# built in (141)
http://wordpress.pastebin.com/BunS9RAk
Anything else you think will work?
Thanks for all the help!
Scott
Well, if your code is working, and $store_couponcat really has what you think it has, then this should work:
query_posts("cat=$store_couponcat");
If that doesn't work, then $store_couponcat does not contain the category id that you are expecting.
This topic has been closed to new replies.