Categories::term_link_filter( string $url, object $term, string $taxonomy )

Description #

Filter category permalink.

Parameters #

  • $url
    string (Required) Default taxonomy url.
  • $term
    object (Required) WordPress term object.
  • $taxonomy
    string (Required) Current taxonomy slug.

Source #

File: addons/categories/categories.php

393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
public function term_link_filter( $url, $term, $taxonomy ) {
    if ( 'question_category' === $taxonomy ) {
        if ( get_option( 'permalink_structure' ) !== '' ) {
            $opt          = get_option( 'ap_categories_path', 'categories' );
            $default_lang = '';
 
            // Support polylang permalink.
            if ( function_exists( 'pll_default_language' ) ) {
                $default_lang = pll_get_term_language( $term->term_id ) ? pll_get_term_language( $term->term_id ) : pll_default_language();
            }
 
            return home_url( $default_lang . '/' . $opt ) . '/' . $term->slug . '/';
        } else {
            return add_query_arg(
                array(
                    'ap_page'           => 'category',
                    'question_category' => $term->slug,
                ),
                home_url()
            );
        }
    }
 
    return $url;
}

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