AnsPress_Category::ap_breadcrumbs( array $navs )

Description #

Add category nav in AnsPress breadcrumbs.

Parameters #

  • $navs
    array (Required) Breadcrumbs nav array.

Source #

File: addons/free/category.php

449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
public static function ap_breadcrumbs( $navs ) {
    if ( is_question() && taxonomy_exists( 'question_category' ) ) {
        $cats = get_the_terms( get_question_id(), 'question_category' );
 
        if ( $cats ) {
            $navs['category'] = array( 'title' => $cats[0]->name, 'link' => get_term_link( $cats[0], 'question_category' ), 'order' => 2 ); //@codingStandardsIgnoreLine
        }
    } elseif ( is_question_category() ) {
        $category = get_queried_object();
        $navs['page'] = array(
            'title' => __( 'Categories', 'anspress-question-answer' ),
            'link'  => ap_get_link_to( 'categories' ),
            'order' => 8,
        );
 
        $navs['category'] = array(
            'title' => $category->name,
            'link'  => get_term_link( $category, 'question_category' ),
            'order' => 8,
        );
    } elseif ( is_question_categories() ) {
        $navs['page'] = array(
            'title' => __( 'Categories', 'anspress-question-answer' ),
            'link'  => ap_get_link_to( 'categories' ),
            'order' => 8,
        );
    }
 
    return $navs;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment