• 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 / yoast_get_primary_term() – Get the primary term name.

Description

Get the primary term name.

Usage

$string = yoast_get_primary_term( $taxonomy, $post );

Parameters

$taxonomy
( string ) optional default: category – Optional. The taxonomy to get the primary term for. Defaults to category.
$post
( int|WP_Post|null ) optional – Optional. Post to get the primary term for.

Returns

string Name of the primary term.

Source

File name: wordpress-seo/inc/wpseo-functions.php
Lines:

1 to 10 of 10
  function yoast_get_primary_term( $taxonomy = 'category', $post = null ) {
    $primary_term_id = yoast_get_primary_term_id( $taxonomy, $post );

    $term = get_term( $primary_term_id );
    if ( ! is_wp_error( $term ) && ! empty( $term ) ) {
      return $term->name;
    }

    return '';
  }
 

 View on GitHub View on Trac

Called by

    Invoked by

      Calls

      1 to 2 of 2
      • yoast_get_primary_term_id() – Get the primary term ID.
      • yoast_get_primary_term() – Get the primary term name.

      Call hooks

      Function name: yoast_get_primary_term
      Plugin ref: Yoast SEO
      Version: 19.1
      Sourcefile: inc/wpseo-functions.php
      File ref: inc/wpseo-functions.php
      Deprecated?: No
      API Letters: G,P,T,Y

      Published: 27th November 2019 | Last updated: 27th November 2019

      Primary Sidebar

      Information

      Function name: yoast_get_primary_term
      Plugin ref: Yoast SEO
      Version: 19.1
      Sourcefile: inc/wpseo-functions.php
      File ref: inc/wpseo-functions.php
      Deprecated?: No
      API Letters: G,P,T,Y

      Footer

      Yoast SEO a2z
      Yoast SEO a2z
      WordPress SEO a2z
      WordPress 6.0
      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