get_term_by example

$prepared_term = $this->prepare_item_for_database( $request );

        $term = wp_update_nav_menu_object( 0, wp_slash( (array) $prepared_term ) );

        if ( is_wp_error( $term ) ) {
            /* * If we're going to inform the client that the term already exists, * give them the identifier for future use. */

            if ( in_array( 'menu_exists', $term->get_error_codes(), true ) ) {
                $existing_term = get_term_by( 'name', $prepared_term->{'menu-name'}$this->taxonomy );
                $term->add_data( $existing_term->term_id, 'menu_exists' );
                $term->add_data(
                    array(
                        'status'  => 400,
                        'term_id' => $existing_term->term_id,
                    )
                );
            } else {
                $term->add_data( array( 'status' => 400 ) );
            }

            
 else {
                    $exclusions .= ' AND link_id <> ' . $exlink . ' ';
                }
            }
        }
    }
    if ( ! empty( $exclusions ) ) {
        $exclusions .= ')';
    }

    if ( ! empty( $parsed_args['category_name'] ) ) {
        $parsed_args['category'] = get_term_by( 'name', $parsed_args['category_name'], 'link_category' );
        if ( $parsed_args['category'] ) {
            $parsed_args['category'] = $parsed_args['category']->term_id;
        } else {
            $cache[ $key ] = array();
            wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
            /** This filter is documented in wp-includes/bookmark.php */
            return apply_filters( 'get_bookmarks', array()$parsed_args );
        }
    }

    $search = '';
    
function wp_get_nav_menu_object( $menu ) {
    $menu_obj = false;

    if ( is_object( $menu ) ) {
        $menu_obj = $menu;
    }

    if ( $menu && ! $menu_obj ) {
        $menu_obj = get_term( $menu, 'nav_menu' );

        if ( ! $menu_obj ) {
            $menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
        }

        if ( ! $menu_obj ) {
            $menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
        }
    }

    if ( ! $menu_obj || is_wp_error( $menu_obj ) ) {
        $menu_obj = false;
    }

    


/** * Retrieves a category object by category slug. * * @since 2.3.0 * * @param string $slug The category slug. * @return object|false Category data object on success, false if not found. */
function get_category_by_slug( $slug ) {
    $category = get_term_by( 'slug', $slug, 'category' );

    if ( $category ) {
        _make_cat_compat( $category );
    }

    return $category;
}

/** * Retrieves the ID of a category from its name. * * @since 1.0.0 * * @param string $cat_name Category name. * @return int Category ID on success, 0 if the category doesn't exist. */
if ( ! array_key_exists( $taxonomy$post_type_taxonomies ) ) {
                        return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
                    }

                    if ( ! current_user_can( $post_type_taxonomies[ $taxonomy ]->cap->assign_terms ) ) {
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
                    }

                    $term_ids           = $post_data['terms'][ $taxonomy ];
                    $terms[ $taxonomy ] = array();
                    foreach ( $term_ids as $term_id ) {
                        $term = get_term_by( 'id', $term_id$taxonomy );

                        if ( ! $term ) {
                            return new IXR_Error( 403, __( 'Invalid term ID.' ) );
                        }

                        $terms[ $taxonomy ][] = (int) $term_id;
                    }
                }
            }

            // Now validate terms specified by name.

function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',
                        $show_description = true, $show_rating = false,
                        $limit = -1, $show_updated = 0) {
    _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );

    $cat_id = -1;
    $cat = get_term_by('name', $cat_name, 'link_category');
    if ( $cat )
        $cat_id = $cat->term_id;

    get_links($cat_id$before$after$between$show_images$orderby$show_description$show_rating$limit$show_updated);
}

/** * Gets the links associated with the named category. * * @since 1.0.1 * @deprecated 2.1.0 Use wp_list_bookmarks() * @see wp_list_bookmarks() * * @param string $category The category to use. * @param string $args * @return string|null */


/** * Returns a link to a post format index. * * @since 3.1.0 * * @param string $format The post format slug. * @return string|WP_Error|false The post format term link. */
function get_post_format_link( $format ) {
    $term = get_term_by( 'slug', 'post-format-' . $format, 'post_format' );
    if ( ! $term || is_wp_error( $term ) ) {
        return false;
    }
    return get_term_link( $term );
}

/** * Filters the request to allow for the format prefix. * * @access private * @since 3.1.0 * * @param array $qvs * @return array */

                }
            }

            // 'cat', 'category_name', 'tag_id'.             foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) {
                if ( empty( $queried_items['terms'][0] ) ) {
                    continue;
                }

                if ( 'category' === $queried_taxonomy ) {
                    $the_cat = get_term_by( $queried_items['field']$queried_items['terms'][0], 'category' );
                    if ( $the_cat ) {
                        $this->set( 'cat', $the_cat->term_id );
                        $this->set( 'category_name', $the_cat->slug );
                    }
                    unset( $the_cat );
                }

                if ( 'post_tag' === $queried_taxonomy ) {
                    $the_tag = get_term_by( $queried_items['field']$queried_items['terms'][0], 'post_tag' );
                    if ( $the_tag ) {
                        $this->set( 'tag_id', $the_tag->term_id );
                    }


    if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id
        || 'post_format' !== $taxonomy || 'revision' === $post->post_type
    ) {
        return $terms;
    }

    if ( 'standard' === $_REQUEST['post_format'] ) {
        $terms = array();
    } else {
        $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' );
        if ( $term ) {
            $terms = array( $term ); // Can only have one post format.         }
    }

    return $terms;
}

/** * Filters post thumbnail lookup to set the post thumbnail. * * @since 4.6.0 * @access private * * @param null|array|string $value The value to return - a single metadata value, or an array of values. * @param int $post_id Post ID. * @param string $meta_key Meta key. * @return null|array The default return value or the post thumbnail meta array. */
$parent      = (int) $args['parent'];

    $slug_provided = ! empty( $args['slug'] );
    if ( ! $slug_provided ) {
        $slug = sanitize_title( $name );
    } else {
        $slug = $args['slug'];
    }

    $term_group = 0;
    if ( $args['alias_of'] ) {
        $alias = get_term_by( 'slug', $args['alias_of']$taxonomy );
        if ( ! empty( $alias->term_group ) ) {
            // The alias we want is already in a group, so let's use that one.             $term_group = $alias->term_group;
        } elseif ( ! empty( $alias->term_id ) ) {
            /* * The alias is not in a group, so we create a new one * and add the alias to it. */
            $term_group = $wpdb->get_var( "SELECT MAX(term_group) FROM $wpdb->terms" ) + 1;

            wp_update_term(
                
if ( str_contains( $name, '-' ) ) {
                $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
            }
        }
        if ( $meta_keys ) {
            $meta_keys = implode( "', '", $meta_keys );
            $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" );
        }
    }

    if ( $wp_current_db_version < 22422 ) {
        $term = get_term_by( 'slug', 'post-format-standard', 'post_format' );
        if ( $term ) {
            wp_delete_term( $term->term_id, 'post_format' );
        }
    }
}

/** * Execute changes made in WordPress 3.7. * * @ignore * @since 3.7.0 * * @global int $wp_current_db_version The old (current) database version. */
Home | Imprint | This part of the site doesn't use cookies.