nataschakater
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemI’m working on a script myself right now but I just can’t figure it out…
What I want is: display the posts when the slug and the category title are equal.
Here is my script so far:
<ul> <?php $categoryName = str_replace(' ', '-', $category->name); $catName = strtolower($categoryName); $product_img = wp_get_attachment_image_src(get_field('product_image'), 'Product Image'); if($category->slug == $catName) { ?> <li><?php the_title(); ?></li> <img src="<?php echo $product_img[0]; ?>" alt="" /> <?php } else { echo "Nothing..."; } ?> </ul>The script works but it only displays the latest post in that category because there is no loop. Anyone can help me finish this code? I really need to figure this out fast.
Thanks!!
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemI copied his code and yeah it seperates the products by category but it’s listed right under each other on one page. I only want the product of the active category page shown. Not all categories + products.
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemHi @georgedk,
Thanks for your reply. I changed ‘products_category’ to ‘types’ but nothing changed. Still the problem of above. It’s not filtering the products by category.
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemOk, I got something…
I changed the rewrite in my Custom Post Type to ‘productitem’ and the file to taxonomy-products_category.php. Now the category page is actually showing the category page!
But… I’m not there yet. If you go to a category page now you can see that both products are in there. There should only be one in there.
Here is the code I used:
<ul class="products"> <?php $args = array( 'post_type' => 'products', 'posts_per_page' => 9, 'paged' => $paged, 'orderby' => 'post_date', 'order' => 'DESC', 'has_archive' => true, 'taxonomy' => 'products_category' ); $loop = new WP_Query($args); while ( $loop->have_posts() ) : $loop->the_post(); $product_img = wp_get_attachment_image_src(get_field('product_image'), 'Product Image'); ?> <li> <a href="<?php the_permalink(); ?>"> <img src="<?php echo $product_img[0]; ?>" alt="" /> </a> <a href="<?php the_permalink(); ?>"> <h2><?php the_title(); ?></h2> </a> <p><?php echo get_field('product_description'); ?></p> </li> <?php endwhile; ?> </ul>Same as my archive-products.php. It should filter them but I’m not sure which code to use.
Thanks.
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemNope, still index.
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemYeah well… I can put some code in category.php but I can’t see the category.php on the frontend so why add some code?
– Added that code, nothing changes on frontend. Categories still using Index.
Thanks for your help btw!
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemHi there,
No the single is working fine. The problem is that my category pages use the Index. I just created a category.php but no luck.
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemWhen I set my permalinks to Default the product page is showing the products correctly but the categories also show BOTH products (the title gives the product name of the product in that category). Changing the permalinks back to Post name gives me Index again.
Forum: Fixing WordPress
In reply to: Custom Post Type with products by Category problemHi, thanks for your reply.
Unfortunately my product page is now redirecting to Index. Category pages too. Already tried to flush my permalinks but no luck.