Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

whiteorange39 on "Custom Taxonomy and Category Problems"

$
0
0

Hello!

Bit green around the edges in php, but I've been currently tasked with fixing my companies old website design (not coded by me) and its been a nightmare.

I have one problem that is particularly tough for me to tackle and that is creating a product page using categories and a custom taxonomy. This was all previously set up but currently looks a bit odd as it displays every product in every category without listing it according to the category hierarchy set up in the front end.

For example:

The page displays as such-

Wardrobes
-Item A
-Item B
-Item C
- etc.

Modern
-Item A
-Item B
-Item C
- etc.

Classic
-Item A
-Item B
-Item C
- etc.

I'd like it list as such:

Wardrobes
-Modern
--Item A
--Item B
--Item C
-- etc.
-Classic
--Item A
--Item B
--Item C
-- etc.

This is how it is set up through the categories in the front end, but I cant quite understand how I'm calling this up wrong in my php.

This is what I have:

<div id="primary" class="site-content">
		<div id="content" role="main">
			<?php $terms = get_terms('productcat');

			    $count = count($terms);
				if ($count > 0) {
			     foreach ( $terms as $term) {?>
				<div class="products-grid">

				<h3><?php echo $term->name; ?></h3>
					<div class="wrap">
			        <?php $loop = new WP_Query(array('productcat' => $term->slug, 'posts_per_page' => 999) );
							$counter = 999;
			            while ( $loop->have_posts() ) :?>

			 			<?php $loop->the_post(); ?>
			            <div class="product">

Any pointers would really help. Thanks.


Viewing all articles
Browse latest Browse all 8245

Trending Articles