• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Featured_Content::hide_featured_term() – Hide featured tag from displaying when global terms are queried from the front end.

You appear to be a bot. Output may be restricted

Description

Hide featured tag from displaying when global terms are queried from the front end.

Hooks into the "get_terms" filter.

Usage

$array = Featured_Content::hide_featured_term( $terms, $taxonomies, $args );

Parameters

$terms
( array ) required – List of term objects. This is the return value of get_terms().
$taxonomies
( array ) required – An array of taxonomy slugs.
$args
( mixed ) required –

Returns

array A filtered array of terms.

Source

File name: twentyfourteen/inc/featured-content.php


Lines:

1 to 32 of 32
  public static function hide_featured_term( $terms, $taxonomies, $args ) {

    // This filter is only appropriate on the front end.
    if ( is_admin() ) {
      return $terms;
    }

    // We only want to hide the featured tag.
    if ( ! in_array( 'post_tag', $taxonomies, true ) ) {
      return $terms;
    }

    // Bail if no terms were returned.
    if ( empty( $terms ) ) {
      return $terms;
    }

    // Bail if term objects are unavailable.
    if ( 'all' !== $args['fields'] ) {
      return $terms;
    }

    $settings = self::get_setting();
    foreach ( $terms as $order => $term ) {
      if ( ( $settings['tag-id'] === $term->term_id || $settings['tag-name'] === $term->name ) && 'post_tag' === $term->taxonomy ) {
        unset( $terms[ $order ] );
      }
    }

    return $terms;
  }
 

 View on Trac

Published: 19th December 2019 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: Featured_Content::hide_featured_term
Class ref: Featured_Content
Plugin ref: Twenty Fourteen
Version: 3.5
Sourcefile: inc/featured-content.php
File ref: inc/featured-content.php
Deprecated?: No
API Letters: C,F,H,T

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
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:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


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

  • Home
  • Blog
  • Sitemap
  • Sites