• Hello Dear

    we recently wrote a code (based on maga category image plugin) to get category images category.php and hide the parent category image in loop.

    <?php
        /*
            Template Name: Test
        */
    
        function displayCategories($arr,$m)
    
        {
            $str = "";
            $str.="
    <ul>";
            foreach($arr as $elem)
            {
                $sub = get_categories("hide_empty=0&parent=".$elem->term_id);
                if(!$sub)
                {
                    $str.='
    <li><a href="#"><img src = "'.$m->getSpecificImage($elem->term_id).'"/></a></li>
    ';
                }
                else
                {
                    $str.='
    <li><a href="#"><img src = "'.$m->getSpecificImage($elem->term_id).'"/></a>';
                    $str.=displayCategories($sub,$m);
    
                    $str.="</li>
    ";
                }
            }
            $str.="</ul>
    ";
            return $str;
        }
    
        $cats = get_categories("hide_empty=0&parent=0");
    
        if($maga)
        {
        echo displayCategories($cats,$maga);
        }
    ?>

    but the code have some problem and i want to fix it with some of changes.
    example :
    the parent category is “hardware”.
    “hardware” have have sub ctegories “monitor” and “speaker”.
    the subcategory “monitor” have childs “LEd monitor” and “LCD monitor”.

    all of parent and subcategoreis and childs have special category image with “maga plugin”.
    when the user click on the category hardware(parent) the subcategories images “monitor and speaker” diplay in category page.(the parent image “hardware” should not be disply.
    and when user click on the subcategory like monitor the image of childs of monitor (Led and lcd) will be display. the monitor now is the parent of led and lcd and does not display .
    and when the user clicks on the child like lcd the post will be displayes now .(no catgeory images now display).

    i hope that the example show that want to do i want to creat and image gallery with this code and i need your help and kindly .
    thank all

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘category images in category.php’ is closed to new replies.