get_categories example

        /** * Fires in the OPML header. * * @since 3.0.0 */
        do_action( 'opml_head' );
        ?> </head> <body> <?php if ( empty( $link_cat ) ) {
    $cats = get_categories(
        array(
            'taxonomy'     => 'link_category',
            'hierarchical' => 0,
        )
    );
} else {
    $cats = get_categories(
        array(
            'taxonomy'     => 'link_category',
            'hierarchical' => 0,
            'include'      => $link_cat,
        )

    $cats  = array();
    $tags  = array();
    $terms = array();
    if ( isset( $term ) && $term ) {
        $cat  = get_term( $term['term_id'], 'category' );
        $cats = array( $cat->term_id => $cat );
        unset( $term$cat );
    } elseif ( 'all' === $args['content'] ) {
        $categories = (array) get_categories( array( 'get' => 'all' ) );
        $tags       = (array) get_tags( array( 'get' => 'all' ) );

        $custom_taxonomies = get_taxonomies( array( '_builtin' => false ) );
        $custom_terms      = (array) get_terms(
            array(
                'taxonomy' => $custom_taxonomies,
                'get'      => 'all',
            )
        );

        // Put categories in order with no child going before its parent.


    /** * Get a category for the feed * * @since Unknown * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1 * @return SimplePie_Category|null */
    public function get_category($key = 0)
    {
        $categories = $this->get_categories();
        if (isset($categories[$key]))
        {
            return $categories[$key];
        }

        return null;
    }

    /** * Get all categories for the feed * * Uses `<atom:category>`, `<category>` or `<dc:subject>` * * @since Unknown * @return array|null List of {@see SimplePie_Category} objects */
return null;
    }

    /** * Get a single category * * @param int $key * @return SimplePie_Category|null */
    public function get_category($key = 0)
    {
        $categories = $this->get_categories();
        if (isset($categories[$key]))
        {
            return $categories[$key];
        }

        return null;
    }

    /** * Get all categories * * @return array|null Array of {@see SimplePie_Category} objects */


    /** * Get a category for the item * * @since Beta 3 (previously called `get_categories()` since Beta 2) * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1 * @return SimplePie_Category|null */
    public function get_category($key = 0)
    {
        $categories = $this->get_categories();
        if (isset($categories[$key]))
        {
            return $categories[$key];
        }

        return null;
    }

    /** * Get all categories for the item * * Uses `<atom:category>`, `<category>` or `<dc:subject>` * * @since Beta 3 * @return SimplePie_Category[]|null List of {@see SimplePie_Category} objects */
if ( ! isset( $parsed_args['class'] ) ) {
        $parsed_args['class'] = ( 'category' === $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy'];
    }

    if ( ! taxonomy_exists( $parsed_args['taxonomy'] ) ) {
        return false;
    }

    $show_option_all  = $parsed_args['show_option_all'];
    $show_option_none = $parsed_args['show_option_none'];

    $categories = get_categories( $parsed_args );

    $output = '';

    if ( $parsed_args['title_li'] && 'list' === $parsed_args['style']
        && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] )
    ) {
        $output = '<li class="' . esc_attr( $parsed_args['class'] ) . '">' . $parsed_args['title_li'] . '<ul>';
    }

    if ( empty( $categories ) ) {
        if ( ! empty( $show_option_none ) ) {
            
// Handle link category sorting.     $direction = 'ASC';
    if ( str_starts_with( $order, '_' ) ) {
        $direction = 'DESC';
        $order = substr($order,1);
    }

    if ( !isset($direction) )
        $direction = '';

    $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0));

    // Display each category.     if ( $cats ) {
        foreach ( (array) $cats as $cat ) {
            // Handle each category.
            // Display the category name.             echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n";
            // Call get_links() with all the appropriate params.             get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false);

            

function wp_dropdown_cats( $current_cat = 0, $current_parent = 0, $category_parent = 0, $level = 0, $categories = 0 ) {
    _deprecated_function( __FUNCTION__, '3.0.0', 'wp_dropdown_categories()' );
    if (!$categories )
        $categories = get_categories( array('hide_empty' => 0) );

    if ( $categories ) {
        foreach ( $categories as $category ) {
            if ( $current_cat != $category->term_id && $category_parent == $category->parent) {
                $pad = str_repeat( '&#8211; ', $level );
                $category->name = esc_html( $category->name );
                echo "\n\t<option value='$category->term_id'";
                if ( $current_parent == $category->term_id )
                    echo " selected='selected'";
                echo ">$pad$category->name</option>";
                wp_dropdown_cats( $current_cat$current_parent$category->term_id, $level +1, $categories );
            }

        elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
        {
            return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
        }

        return null;
    }

    public function get_category($key = 0)
    {
        $categories = $this->get_categories();
        if (isset($categories[$key]))
        {
            return $categories[$key];
        }

        return null;
    }

    public function get_categories()
    {
        $categories = array();

        


        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
        do_action( 'xmlrpc_call', 'wp.suggestCategories', $args$this );

        $category_suggestions = array();
        $args                 = array(
            'get'        => 'all',
            'number'     => $max_results,
            'name__like' => $category,
        );
        foreach ( (array) get_categories( $args ) as $cat ) {
            $category_suggestions[] = array(
                'category_id'   => $cat->term_id,
                'category_name' => $cat->name,
            );
        }

        return $category_suggestions;
    }

    /** * Retrieves a comment. * * @since 2.7.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $0 Blog ID (unused). * @type string $1 Username. * @type string $2 Password. * @type int $3 Comment ID. * } * @return array|IXR_Error */
Home | Imprint | This part of the site doesn't use cookies.