WordPress.org

Ready to get started?Download WordPress

Forums

Generate category LINK and TITLE from ID (5 posts)

  1. cavamondo
    Member
    Posted 3 years ago #

    Is there away to generate a link with category name to a category from a category ID

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    http://codex.wordpress.org/Function_Reference/get_category_link
    http://codex.wordpress.org/Function_Reference/get_cat_name

    <?php $cat_id = 123; ?><a href="<?php echo get_category_link($cat_id); ?>"><?php echo get_cat_name($cat_id); ?></a>

  3. cavamondo
    Member
    Posted 3 years ago #

    Excellent it works .. thx ^^

  4. cavamondo
    Member
    Posted 3 years ago #

    Another thing, is it also possible to generate a list with subcategories as links, from a defined topcategory.

    Example i have a top category called "sport" with ID 10 .. from this top category i wish to genrate a list of all this top category's subcategories.

    Is this possible?

  5. cavamondo
    Member
    Posted 3 years ago #

    Edit found out .. heres for other to use:

    <?php wp_list_categories(’show_count=1&child_of=154&title_li=<h2>Category name</h2>’); ?>

    154 is the ID

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.