AVADA WordPress Custom Taxonomy Sidebar

I have a custom WordPress Taxonomy called ‘directory-category’ with posts sitting in each relevant category within the taxonomy.

I’m using the Avada template with a hope to use their sidebar mechanism, however I’m unable to modify (successfully) this code to not list page ancestors, but rather, listing categories within the taxonomy and then the posts within the categories.

Read More

Here is the current sidebar helper function building a sidebar menu based on pages / page ancestors;

$html = '<ul class="side-nav">';

        $post_ancestors = get_ancestors( $post_id, 'page' );
        $post_parent = end( $post_ancestors );

        $html .= '<li';
        if( is_page( $post_parent ) ) {
            $html .= ' class="current_page_item"';
        }

        if( $post_parent ) {
            $html .= sprintf( '><a href="%s" title="%s">%s</a></li>', get_permalink( $post_parent ), __( 'Back to Parent Page', 'Avada' ), get_the_title( $post_parent ) );
        } else {
            $html .= sprintf( '><a href="%s" title="%s">%s</a></li>', get_permalink( $post_id ), __( 'Back to Parent Page', 'Avada' ), get_the_title( $post_id ) );
        }

        if( $post_parent ) {
            $children = wp_list_pages( sprintf( 'title_li=&child_of=%s&echo=0', $post_parent ) );
        } else {
            $children = wp_list_pages( sprintf( 'title_li=&child_of=%s&echo=0', $post_id ) );
        }
        if ( $children ) {
            $html .= $children;
        }

        $html .= '</ul>';

        return $html;

I really would appreciate the help if someone is able to assist!

Related posts

Leave a Reply