Forums

hot to display the category on Dukapress Grid (5 posts)

  1. onirisweb
    Member
    Posted 1 year ago #

    Hi,

    Everything is written in the title !

    So I am looking for a function to display the categories to which each product belongs when it is displayed in the grid view catalog. I would like at the same time to display them on link : clicking on each category will display all the products depending of this category (so a new catalog grid view).

    On the dp-products.php file, I implemented this function :

    $categories = get_the_category($product->ID);
    foreach ($categories as $category)
    {
         $arrayCat[] = $category->cat_name;
    }
    
    if (isset($arrayCat))
       $content .= implode (' | ', $arrayCat);

    The matter is that the word "array" is displayed with the category name. The categories are duplicated when there are 2 or more products belonging to the same category that are displayed.

    And I also don't know how to implement the code for the link.

    Someone can help me ?

    Thanks

  2. moshthepitt
    Member
    Posted 12 months ago #

    Sorry I haven't quite got what you mean.

    You mean you want to display the category name like here: http://madoido.com/begi/?cat=10

    The category name there is the page's title.

  3. moshthepitt
    Member
    Posted 12 months ago #

    And sorry for the delayed response!

  4. onirisweb
    Member
    Posted 11 months ago #

    Hi, no matter for the delayed response !

    It's not exactly what I want. I would like that in your example under goatman mask (and for all the other products also) all the categories to which this product is linked appear. And I would like to be able to click on this categories, which will display all the products that they manage.

    Thanks for your answer

  5. moshthepitt
    Member
    Posted 11 months ago #

    I think this is fairly simple :P

    First, you need to make sure that the category pages produced will display DUkaPress products. This is a theme issue. You can see how to do this here: http://dukapress.org/blog/2011/02/26/dukapress-category-pages/

    This ensures that when the category names are clicked, they lead to the correct place.

    Next, you need to edit (or create) a single-duka.php file which will handle how the single product pages are shown. You can base it off of your theme's single.php

    Somewhere in your single-duka.php, include code that is a little like this:
    <?php echo('Filed in'); ?>: <?php the_category(', ')?>

    Should work. :)

    I have done it here: http://madoido.com/shopkeeper/?duka=double-vessels

    Please note that all of the changes above are done within your theme files. If you switch to another theme, things will change.

Topic Closed

This topic has been closed to new replies.

About this Topic