NexxGenDrue
Member
Posted 1 year ago #
This is what I have..
<?php query_posts(array("cat" => "7"));
if(have_posts()): ?>
This works to display my 'bags cat (7)' but i have a template, and need all my categories to feed off this one template, so instead of defining what cat id, i need it to get the cat id of the page your on, and display the product under that cat. I know its probably simple but im not to advanced yet. Thanks in advance!!!
<?php query_posts(array("cat" => get_query_var('cat')));
if(have_posts()): ?>
but this is the default in the category archive, anyway ...
NexxGenDrue
Member
Posted 1 year ago #
Thanks alot for the input, but when used code u gave, it got all my post and displayed, and stripped my css for it for some reason. Any other ideas?
http://militarypewter.com/?p=544
I know theirs got to be a way to display all my product from the category the post belongs to.
display all my product from the category the post belongs to.
that is different.
in a post, you get the posts categories (there could be more than one) with get_the_categories():
http://codex.wordpress.org/Function_Reference/get_the_category
<?php $post_cats = get_the_categories($post->ID);
foreach($post_cats as $post_cat) { $cats[] = $post_cat->term_id; }
$args = array(
'posts_per_page' => -1,
'category__in' => $cats
); ?>
<?php query_posts( $args );
if(have_posts()): ?>
NexxGenDrue
Member
Posted 1 year ago #
Thanks alot! Your there, but if you look at that link again you can see what its doing. Its messing it up somehow, but still pulling from the category, it also pulled the post itself and put there too.
there are ways to prvent this:
http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action
you could paste the code of your template into a http://pastebin.com/ and post the link ot it here.
someone might be able to make a suggestion how to prevent the duplicate post to show.
NexxGenDrue
Member
Posted 1 year ago #
http://pastebin.com/J2VgaKdR
Can anyone else help?
It is now pulling from that category but messing up the css and pulling the post its on as well.
NexxGenDrue
Member
Posted 1 year ago #
Im not the best at this yet, but im trying.
Isn't what im trying to achieve right now starting the loop?
The purpose here is that im changing my site from pages to post that way I have better control. I need BAGS to show bags, CHAIRS to show chairs, etc. The only way I thought of was making them categories and displaying the categories for the page your on. I could make a new page template for each cat and say 'query post display cat id' but that seems sloppy.
Im open to new ideas. But im new with this post thing and would love to learn.