• I’m not understanding something with get_links in sidebar.php.

    Here is the line from the file:
    <?php get_links('-1', '<li>', '</li>', '<br />','','category',FALSE); ?>

    How do I get it to show the link category? Right now they are all showing up as a single list, although they are indeed sorted by category.

    I’m using WP 1.51 alpha and the Rin template.
    Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter craighartel

    (@craighartel)

    Oh, duh.

    Use get_links_list instead of just get_links and all is well. Thank you Codex.

    Best thing to do is ignore that tag ?
    <ul>
    <li id="here">Here
    <ul><?php wp_get_links(11); ?></ul>
    </li>

    The number in (brackets) is the Cat ID and doing it this way not only gives you separated categories, but you ALSO get to order the categories in any way you want, AND if you use 3 columns you can display different cats across the columns AND (yes, there’s more!) this way also allows for full and easy CSS control.

    You know it makes sense ??

    Or wp_get_linksbyname(‘cat name’), so you don’t have to remember which category is number 11.

    Thread Starter craighartel

    (@craighartel)

    Thanks, guys. I’ll have to mess with those later, as it’s nearly time to head to work.

    I couldn’t ignore the get_links tag as I needed a way to display all links plus categories and descriptions on the main links page (using get_links_list) but on the front page I only wanted 2 categories and no descriptions – using get_links achieved this, but as Craig pointed out it doesn’t display categories – I finally came up with the following:

    <?php
    $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories WHERE cat_id=1");
    foreach ($link_cats as $link_cat) {
    ?>
    <li id="linkcat-<?php echo $link_cat->cat_id; ?>"><?php echo $link_cat->cat_name; ?>

      <?php get_links($link_cat->cat_id, '

    • ', '
    • ', '', FALSE, 'url', FALSE); ?>

    <?php } ?>

    repeat the above for each category you wish to show, changing “WHERE cat_id=1” to the relevant category. Not sure if this is the most elegant solution, but it works!

    For an update to WP, can we have a parameter on link categories for show_on_sidebar or something like that? It would make it a lot more versatile

    Yes! Thank you this works perfect for me, i also just wanted to display only one category, with the category title and the links!
    Great!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to show link category’ is closed to new replies.