get_category_link example

$categories_struct = array();

        $cats = get_categories( array( 'get' => 'all' ) );
        if ( $cats ) {
            foreach ( $cats as $cat ) {
                $struct                        = array();
                $struct['categoryId']          = $cat->term_id;
                $struct['parentId']            = $cat->parent;
                $struct['description']         = $cat->name;
                $struct['categoryDescription'] = $cat->description;
                $struct['categoryName']        = $cat->name;
                $struct['htmlUrl']             = esc_html( get_category_link( $cat->term_id ) );
                $struct['rssUrl']              = esc_html( get_category_feed_link( $cat->term_id, 'rss2' ) );

                $categories_struct[] = $struct;
            }
        }

        return $categories_struct;
    }

    /** * Uploads a file, following your settings. * * Adapted from a patch by Johann Richard. * * @link http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/ * * @since 1.5.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @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 array $3 Data. * } * @return array|IXR_Error */
$thelist = '';
    if ( '' === $separator ) {
        $thelist .= '<ul class="post-categories">';
        foreach ( $categories as $category ) {
            $thelist .= "\n\t<li>";
            switch ( strtolower( $parents ) ) {
                case 'multiple':
                    if ( $category->parent ) {
                        $thelist .= get_category_parents( $category->parent, true, $separator );
                    }
                    $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name . '</a></li>';
                    break;
                case 'single':
                    $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>';
                    if ( $category->parent ) {
                        $thelist .= get_category_parents( $category->parent, false, $separator );
                    }
                    $thelist .= $category->name . '</a></li>';
                    break;
                case '':
                default:
                    $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name . '</a></li>';
            }
Home | Imprint | This part of the site doesn't use cookies.