• Resolved agatasz

    (@agatasz)


    Hello dears,

    I want to use templates to make a Taxonomy page that displayes a parent and all children.

    I use taxonomy.parent to get the id, and a function mentioned in this support forum to get the name of the taxonomy. But I do not see equivalent taxonomy.child to be able to use it in [each] function.

    I don’t want to jump to php page yet, I know they give more functionalities, but I don’t feel comfortable mingling with that now. But I am more than happy o use custom functions in child theme.

    Is there a easy solution?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @agatasz

    I honestly don’t believe we support such traversal of taxonomies in our tags.
    PHP would be your best shot for a short-term solution.

    However, I do feel like this would be a nice addition to Pods. Feel free to add a feature request on GitHub and tag me there!
    pods.io/submit

    Cheers, Jory

    Thread Starter agatasz

    (@agatasz)

    I did that, thanks!
    -> https://github.com/pods-framework/pods/issues/7022

    In the meantime, I made myself a dirty workaround if someone else wanders here (child theme functions.php)

    
    /* Print list of children for a taxonomy */
    function print_term_children( $term_id ) {
        $categories_print = '<ul style="line-height:80%">' ;
        //echo $term_id;
        
        $args = array('parent' => $term_id,
                      'taxonomy' => 'label'
                    );
    
        $categories = get_categories( $args );
        if(!empty($categories)){
            echo "<b>Sub-Labels:</b>";
            
        }
        foreach ( $categories as $category ) {	
            if ($category->term_id <> $term_id) {
                $categories_print = $categories_print . '<li>' . '<a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a>'; 
                
                $mypod = pods( 'label', $category->term_id);
                var_dump($mypod); 
                //echo $mypod;
                pods_field_display ( 'label', $category->term_id, 'name' );
                
                $params = array( 
                    'where'   => 't.id LIKE "$category->term_id"', 
                    'limit'   => -1  // Return all rows 
                ); 
                $labels = pods( 'label', $params ); 
                
                            
                if ( 0 < $labels->total() ) { 
                        while ( $labels->fetch() ) { 
                ?> 
                        <h2><?php echo $labels->display( 'name' ); ?></h2> 
                        <p>Author: <?php echo $labels->display( 'logo' ); ?></p> 
                        <br /> 
                        <br /> 
                <?php 
                        } // end of labels loop 
                    } // end of found labels            
                
                
                
    
            }
        }
        $categories_print = $categories_print . "</ul>";
        return $categories_print; 
    }
    

    Plugin Author Jory Hogeveen

    (@keraweb)

    Great, thank you!

    Cheers, Jory

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Template: Display Taxonomy children’ is closed to new replies.