• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Yoast SEO a2z

Yoast SEO a2z

WordPress SEO a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / WPSEO_Rewrite::no_category_base() – Override the category link to remove the category base.

You appear to be a bot. Output may be restricted

Description

Override the category link to remove the category base.

Usage

$string = WPSEO_Rewrite::no_category_base( $link, $term, $taxonomy );

Parameters

$link
( string ) required – Term link, overridden by the function for categories.
$term
( WP_Term ) required – Unused, term object.
$taxonomy
( string ) required – Taxonomy slug.

Returns

string

Source

File name: wordpress-seo/inc/class-rewrite.php
Lines:

1 to 23 of 23
  public function no_category_base( $link, $term, $taxonomy ) {
    if ( $taxonomy !== 'category' ) {
      return $link;
    }

    $category_base = get_option( 'category_base' );

    if ( empty( $category_base ) ) {
      $category_base = 'category';
    }

    /*
		 * Remove initial slash, if there is one (we remove the trailing slash
		 * in the regex replacement and don't want to end up short a slash).
		 */
    if ( substr( $category_base, 0, 1 ) === '/' ) {
      $category_base = substr( $category_base, 1 );
    }

    $category_base .= '/';

    return preg_replace( '`' . preg_quote( $category_base, '`' ) . '`u', '', $link, 1 );
  }
 

 View on GitHub View on Trac

Published: 27th November 2019 | Last updated: 2nd May 2020

Primary Sidebar

Information

Function name: WPSEO_Rewrite::no_category_base
Class ref: WPSEO_Rewrite
Plugin ref: Yoast SEO
Version: 19.1
Sourcefile: inc/class-rewrite.php
File ref: inc/class-rewrite.php
Deprecated?: No
API Letters: B,C,N,R,W

Footer

Yoast SEO a2z
Yoast SEO a2z
WordPress SEO a2z
WordPress 6.0.1
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wordpress-seo.wp-a2z.org
© Copyright Yoast SEO a2z 2017-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites