Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9294

    Hi,

    I would like to display a link to the product parent category on a single product page. It should be like a breadcrumb but it should only have the name of the parent category.

    For example:

    Product CAT 1

    - Product X

    - Product Y

    When being on the product X page, a link should be displayed to Product CAT 1. Right now the breadcrumb looks like this:

    Home » Shop » Product category slug » Product name

    The Product category slug is always the same as it is the name configured at WooCommerce=>settings=>pages under ‘Permalinks’. I think we should edit some code in the class-breadcrumb.php file located in abundanceframeworkphp

    This is some code of the original class-breadcrumb.php file that I use:

    /* Open the breadcrumb trail containers. */

    $breadcrumb = '<div class="breadcrumb breadcrumbs avia-breadcrumbs"><div class="breadcrumb-trail">';

    /* If $before was set, wrap it in a container. */

    if ( !empty( $before ) )

    $breadcrumb .= '<span class="trail-before">' . $before . '</span> ';

    /* Wrap the $trail value in a container. */

    if ( !empty( $trail ) )

    $trail = '<span class="trail-end">' . $trail . '</span>';

    /* Format the separator. */

    if ( !empty( $separator ) )

    $separator = '<span class="sep">' . $separator . '</span>';

    /* Join the individual trail items into a single string. */

    $breadcrumb .= join( " {$separator} ", $trail );

    /* If $after was set, wrap it in a container. */

    if ( !empty( $after ) )

    $breadcrumb .= ' <span class="trail-after">' . $after . '</span>';

    /* Close the breadcrumb trail containers. */

    $breadcrumb .= '</div></div>';

    }

    /* Allow developers to filter the breadcrumb trail HTML. */

    $breadcrumb = apply_filters( 'avia_breadcrumbs', $breadcrumb );

    /* Output the breadcrumb. */

    if ( $echo )

    echo $breadcrumb;

    else

    return $breadcrumb;

    } // End avia_breadcrumbs()

    Any ideas to achieve this?

    Thanks and keep up the good work. I love this theme!

    #64218

    Never mind. I already solved this by using this code:

    <?php echo $_product->get_categories( ', ', ' <span class="posted_in">'.__('Category:', 'woothemes').' ', '.</span>'); ?>

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

The topic ‘get parent category from product’ is closed to new replies.