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

	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