If you have used DukaPress for any length of time, it is probable that you have come across something really annoying: products do not show up on your categories. Additionally, if you want to create pages which show your products using the grid view, you currently have to go through the painful process of creating separate pages for each category, then inserting the gird view shortcode into each page. This is less than ideal. Explaining this process to a client becomes ‘difficult’.
What if each category could just automatically show your products in the gird view without the need of you doing anything other than just…. putting your products in their respective categories? With help from Cookie Web, we’ve figured out a way to do just this.
How do you do this?
Basically, you need to create a custom category template for your theme and make it such that when your categories are viewed, the grid display shortcode is used to generate a page that shows your products nicely.
Every theme’s category templates will be different in terms of HTML and CSS but to achieve what we are describing you just need two pieces of code:
A. This code gets the category ID of the category being viewed
B. This code then inserts the category ID into the grid display shortcode so that you can generate your product category pages:
C. Optionally, you can use this bit of code to print the category name somewhere on the page:
name ?>
See it in action
Our latest themes Mwendo, Sanaa, Begi and ShopKeeper already include this functionality. You can download them to see exactly how we implemented this. You can view their demos to see it in action – make sure you click on the categories!
Thank you for this!!
I got the code to somewhat work except above the products it’s displaying
“Not Found
Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.”
and a search box…. I’m unsure of how to get rid of that.
I figured it out!!! Thank you again
I’m glad you managed to do it. 🙂 Good lookin site btw
Hello there,
I’m really noob programmer and i’d love to know where the heck to put that code 😛
Sorry for being such an idiot and thanks for your help!
Hey Sebastian!
Most themes have either: archive.php, category.php, or index.php. You need to take one of these files (back up :P) and then look at the code, you will notice that generally there is a php “while” statement, followed by “if” and “else if”. These are where the theme is calling the loop to display the category contents.
Somewhere, you will notice something like the_content or the_excerpt inside a php statement. This is where a post;c content is displayed. So delete the php there and put in all the code above instead.
Then go through the rest of the file and delete all the other php while and if statements. make sure to leave all the “div” statements in tact.
If you do this, then rename your file “category.php” and you’ll be done.
I have generalised things because of the sheer number of themes and all their different approaches, but its the basic procedure.
Kelvin thank you very much!!!
I have solved it!!!
Anyway now im having problems with my styles but i’ll try fix it myself 🙂
no, i thought it was working but it didn’t…
Hey Kelvin!
I tried following your good advice, but im not good enough and i brake down all the file ROFL!
This is the archives.php in my theme; i tried deleting all the “if” and “else” below “while” but still can’t make it work 🙁
Pastebin: http://pastebin.com/kyX3BcLb
Wow, really complex archives there. What theme is this? I’ll try create category.php using one of the other files
it’s called “Kidz”, and yeah i thought the same when i first saw it, it’s not like the other ones :S
Thanks for giving it a try mate 🙂
PS: You can get the them from here : http://www.wordpressthemes.es/558/kidz-green/
Done. Please check pastebin, I posted it on the same place you had: http://pastebin.com/EyMzGrju
thank you mate…i really appreciate it 🙂
hello
i am using the default wordpress twenty ten theme and looked through the index, archives and category files and found no “while” statement. i am just not getting where the 2 pieces of code go…….
i would love to make this work. thanks
This is extremely easy to do with TwentyTen 😛
Here, paste this in category.php : http://pastebin.com/K6Kkvnts
Thanks for the code. got it place and works!.
the only downside is before when you clicked on a product category (the old way from a dropdown in the menu) you would get a page with a description about the product and the i used the product grid shortcode.
i tried editing the category by putting in a description. unfortunately the twenty ten theme doesn’t show it by default.
i’ll work on finding a way to get this done.
thanks again.
If you use the code I sent, this will show the cat description:
Reference: http://codex.wordpress.org/Function_Reference/category_description
Got the code for category description in place and works great. thanks for all your help.
Your site looks really good btw! I’m happy that all’s working okay. If you have a moment, please consider rating us on wordpress.org: http://wordpress.org/extend/plugins/dukapress/
So i logged in a gave you a 5 star rating and it made you have the “green works!” status. thanks, yeah, the website is a work in progress, but coming along.
Thanks Paul!
will you help me to changes the code , which i used http://demo.themesbell.com/fashionable/ for the themes, really i blind on coding…thx,,very2 simple shopping cart’..two thumbs Up
I’d love to help – but you gotta make an effort too. Where have you installed DukaPress? I cannot see your products.
i installed in my web http://www.addnique.com cek it out,..?are you need to email archieve.php..?
here is
ID);
//$num_comments = $num_comments->approved;
$i++;
?>
<div class=" post_box” id=”post-“>
ID);
$pattern= “/(?post_content;
$searchimages = ‘~]* />~’;
/*Run preg_match_all to grab all the images and save the results in $pics*/
preg_match_all( $searchimages, $content, $pics );
// Check to see if we have at least 1 image
$iNumberOfPics = count($pics[0]);
if ( $iNumberOfPics > 0 ) {
// Your post have one or more images.
$imgTagFirst = $pics[0][0];
$pattern= “/(?
<a href="” title=””><img src="/include/timthumb.php?src=&h=&w=&zc=1″ alt=”” title=”” />
<div class="”>
<div class="”>
<h1 class="”><a href="” title=””>
<p class="”>// | <a href="” class=”” title=””> <img src="/images/comment_icon.png” alt=”” title=”” />
Sorry
No posts found.
<?php /*
*/ ?>
Please email the whole theme folder to duka(at)dukapress.org
i have already sent it …i need to ask , about checkout step..when the cart is checkout by buyer, is there any report to seller email..? or it must be cek in order LOg..??
An email is sent to both the admin (seller) and the customer
Hi All,
Am I correct in assuming that I MUST use the shortcodes to display products?
I tried to just loop through the post_type duka but that did not work 🙁
Thanx,
Daniel
It is not correct to say that because at the end of the day the products and related info are just a custom post type (named ‘duka’) with custom fields (for price, weight, variations, etc). So you can definitely loop through the post type and display them but keep in mind to call the custom fields.
The only thing that will be problematic with this method will be:
1. displaying the “add to cart” button.
2. displaying the images using the DukaPress image effects – you will just get attached images the normal WordPress way
But I am certain that you can re-use the code in dp-products.php to do much more than our shortcodes do 🙂
Thanx Kelvin, but it won’t work for me.
Here is the query I set up:
query_posts( ‘post_type=duka&posts_per_page=12&paged=’.$paged.” );
and I get a page with the title Boutique and the author’s name. I am using the_content(); and am not getting the content. I have not tried to get the
meta data.
Am I missing something? I use custom post types all over the place so I figured this should wor. Any ideas?
Thanx in advance,
Daniel
OK, so while editing the template file I deleted my if( have_posts () ….
So it was me. All is good 🙂
Thanx,
Daniel
Oh good! I was scratching my head wondering why it wasn’t working. Good luck on what you’re working on. Share the link when done!
HI All,
I was just wondering if it was possible to set my Product Variations ( Sizes, Colors, etc ) as a Master Dropdown list. My client has multiple products that use the same set of sizes and it would make her life a lot easier if she did not have to enter each size every time she enters a new product.
Is there a way to set these so all she has to do is select for example “T-Shirt sizes” or “Sleepwear Sizes” depending upon the product.
Thanx,
Daniel
Hi,
i’ve been searching what’s wrong with all the widgets positions when a category is clicked.
those widgets top position is somehow pushed down as if the product grids are placed above them. in other word, the sidebar layout is messed when i clicked on the category name. ie. http://www.lamozeshop.com/category/import-collection/
this is only happening when i clicked on categories. the widgets are placed properly when i open a specific product’s page, the searched results, an even on a page with product grids shortcode.
can you help me, please?
thanks in advance,
LD
Hey LD. How are you? Unfortunately we cannot do much to help you. The category page is loaded using your themes category template. The problem here is to be found in your category template inside your theme. It is probably something really tiny, too.
Hey Kelvin, thanks for your response. The problem is… the theme (http://wordpress.org/extend/themes/pretty-theme) does not have any category template. So by default, it cannot displays the grid at all.
So I “borrowed” the category.php from shopkeeper theme, and it works fine, except on the category page. It seems that the sidebar is somehow placed after the category content (which is the grids).
thank you,
LD
Hmm, not a good idea to do that. It would have been better & easier to use archive.php or even index.php
All the same, I managed to make it okay for you using your theme’s archive.php. Enjoy:
http://pastebin.com/CvsEAh88
Hi Kelvin,
this afternoon, I managed to make fix it by adding class = “narrowcolumn” at the first div line. hahaha… inspired by the pretty theme original page.php file content. 😀
want to post comment here but my connection got problem.
once i can online, i tried your template based on pretty theme’s archive.php. but somehow it does not even shows the grid at my site. 🙁 so i undo it and switched back to my “fixed” version.
here it is: http://pastebin.com/EMe5XJRf
again… thank you for your help Kelvin.
oh yeah… i think DP needs a forum to discuss problems and for more hacks to make it more and more compatible. 😀
good luck for you and DukaPress!
sincerely,
LD
Hey, Kelvin,
I am trying to do this to my FlexxCamo theme, but it just isn’t working. Maybe I am doing it wrong, could you explain how to do it for the FlexxCamo theme?
Thanks
Really hard to help you out with such little info, sorry. Could you possibly give us temporary admin access? (duka.at.dukapress.org)
As far as I can tell, I’ve done everything correctly thus far. I’m getting the error “Warning: Division by zero in /home4/homemae0/public_html/wp-content/plugins/dukapress/php/dp-products.php on line 326” on my product page called “Candles.” I went in through my cPanel, opened this doc, and went to line 326. There’s no 0 in it at all.
Thanks in advance for your help.
Hmm, may I see your site?
That would be helpful, wouldn’t it? 🙂 http://www.homemadebymarie.com
The products are listed on candles page sad votives page.
Can you please give me temporary admin access? my email: duka(at)dukapress.org
Done. that was supposed to be *and votives page.
The problem is caused by a plugin called “Dean’s FCKEditor With pwwang’s Code Plugin For WordPress”. This plugin messes up the shortcodes by introducing spaces and other other characters. (See this page for what I mean: http://www.homemadebymarie.com/wp-admin/post.php?post=30&action=edit)
I deactivated the plugin and fixed up one page: http://www.homemadebymarie.com/scented-candles/votives/
Thanks so very much! It looks awesome. Any ideas why my thumbnails aren’t showing?
Maybe this is why? http://dukapress.org/blog/2011/02/19/dukapress-images-not-working/
Hey there. I’m a bit new to all this (had the site since Jan). I havent messed too much with the site in a couple months, but when I came back to it, one of my pages was not displaying the products in grid form. This is weird to me because one of my other pages is displaying the grid just fine and everything has the proper short codes. It seems as if something is overriding the shortcode on that one page because it is displaying all my products as if they were all individual posts. Very weird. Anyway, if there is any advice you can give me, that would be great!
BTW…none of this happened until I updated Dukapress. Thanks again!
Which page is this, could you give the URL?
Yes, the URL for the site NOT displaying the grid is :
http://graffitifacecosmetics.com/products/
It displays it to where it looks more like individual blog posts.
The URL for the sire actually displaying the grid properly is:
http://graffitifacecosmetics.com/awareness-products/
Thanks in advance!
I believe this is because of the url: http://graffitifacecosmetics.com/products/. If you change it to http://graffitifacecosmetics.com/product or http://graffitifacecosmetics.com/shop it will work.
Hey there. I tried to change it over and all it said was “Error”. Im just going to have to do away with Dukapress. I hate that I have to, but me and Duka have never gotten along. Thanks anyways!
Sad to see you go 🙁
Even though you want to remove it, solving this issue is incredibly easy. Just go to your page (the Products page), go into the edit screen and change the URL..
I tried that and it did not work, but I will tell you what did…for SOME odd reason…the category ID number changed in the Dukapress Shortcode..so for anyone having this problem..make sure your category ID number is correct. Ever since I updated Dukapress, the category ID number changed. Thanks for all your help!
-Amber
Keep up the great work of providing us with useful information.
Hi there!
First I want to thank you for such a great plugin. I was hesitant at first, and chose Dukapress solely because I can use integrated Alertpay, but now I’m glad I have it for other reasons as well.
I am having a heck of a time getting this to work. I have tried several different variations, but none of them function 100%. The link below is the version that has worked the best so far, as well as the original file. The link in my name will take you right to an example page on my site in progress.
http://pastebin.com/8Pi8SWWa
Thanks again for a great product. I have several of the premium modules, and they certainly streamline a lot of things for me. What I notice most about Dukapress is the level of support. I have never seen anyone give such direct, hands-on support.
Thanks Justin. Sorry it took long to get back to you. Please use the forums for faster response next time 🙂
If you can send this theme to duka(at)dukapress.org, we’ll sort it out and send it back 🙂
Thank you for your kind words, VERY much appreciated.
Hello
Plug in your WordPress plugins I use and it is great
I do not know where this program should be written to accommodate
If you are on the tags and how they can help
Persian-speaking friend, I am
Thank you