Forums

wp_list_categories link varbiale (3 posts)

  1. expromo
    Member
    Posted 2 years ago #

    Hi everyone!

    I had some issues with wp_list_categories and now I'm using get_categories. All is well but I don't know what should I put in my href="" for it to be universal.

    In wp_list_categories the categories are links by default - here they are text and I want the link to be universal (to work both when permalinks are display postname or ID - you know what I mean).

    This is my code:

    <?php
    echo '<ul id="main-categories-list">';
    $cat = get_query_var('cat');
    foreach(get_categories("orderby=name&order=ASC&child_of=".$cat."&hide_empty=0") as $category) {
    echo '

  2. '.$category->cat_name.'
    '.$category->description.' '.get_cat_icon("echo=0&cat=".$category->cat_ID).'
  3. ';
    }
    echo '';
    ?>

    What should I put in my ?
    Thanks for your help!

  • MichaelH
    Volunteer
    Posted 2 years ago #

    echo '<p>Category <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> has ' . $category->count . ' post(s). </p> ';
  • radiofranky
    Member
    Posted 2 years ago #

    Hi MichaelH,
    I was wondering how to limit display to 8? and also is there a way to select categories randomly and display with get_cat_icon?

    thanks

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags