ID : 0; } return $id && 'publish' === get_post_status( $id ) && is_post_type_viewable( get_post_type( $id ) ) ? (string) get_the_title( $id ) : ''; } /** * Name of a category, tag or product category whose archive is at a path. * * @param string $path Path without query. * @return string */ private static function term_title( $path ) { $slug = basename( untrailingslashit( $path ) ); if ( '' === $slug ) { return ''; } foreach ( get_taxonomies( array( 'public' => true ) ) as $taxonomy ) { $term = get_term_by( 'slug', sanitize_title( $slug ), $taxonomy ); if ( ! $term ) { continue; } $link = get_term_link( $term ); if ( ! is_wp_error( $link ) && untrailingslashit( (string) wp_parse_url( $link, PHP_URL_PATH ) ) === untrailingslashit( $path ) ) { return $term->name; } } return ''; } }