• jmprice

    (@jmprice)


    Hi, I just started up a new blog on https://culturespace.org.

    My question:
    Currently I have two categories of links: “Blogroll” and “Media”.

    I would like to separate these two categories on my sidebar, but WordPress combines them.

    This is the code in my sidebar:
    <h2 class=”sidebar-title”>Blogroll</h2>
    <?php get_links(‘-1’, ”, ‘
    ‘, ‘
    ‘, 0, ‘name’, 0, 0, -1, 0); ?>

    How do I get it to call for only one category?

    Thanks,

    Joe

Viewing 9 replies - 1 through 9 (of 9 total)
  • iand

    (@iand)

    <?php wp_get_linksbyname('link cat name here'); ?> should do the job.

    The -1 at the beginning of the parameters in get_links tells WP to grab the links from all categories. Go into WP’s Link Manager and check what the category ID is for your Blogroll & Media categories. Then replace that line with something like this:
    <h2 class="sidebar-title">Blogroll</h2>
    <?php get_links('0', '', '
    ', '
    ', 0, 'name', 0, 0, -1, 0); ?>
    <h2 class="sidebar-title">Media</h2>
    <?php get_links('1', '', '
    ', '
    ', 0, 'name', 0, 0, -1, 0); ?>

    The Codex covers this under Template Tags/get links.

    Thread Starter jmprice

    (@jmprice)

    Manzabar, you are brilliant and quick. Thank you.

    Nah, the brilliant one is whoever wrote up the excellent article in the codex. I’ve just been riding on their coattails. ??

    Root

    (@root)

    You could do it in CSS by applying the relevant selector for link cats. No php necessary.

    From looking at WP 1.5 classic theme, it looks like one can do something similar with just <?php get_links_list(); ?> and some CSS styling as Root suggested but if you have more link categories and you don’t want them all appearing in your sidebar*; then I’d stick with what I described above.

    * As an example, I’ve been working on a theme for 1.5 for my eventual upgrade and I’m storing the links for the theme’s navbar in WP’s Link Manager. I wouldn’t want those links to show up with the rest of the links in WP’s Link Manager so using get_links_list() wouldn’t work for me.

    Root

    (@root)

    Well the question was how to separate – not to only show one ??

    @root: Good point. I guess I’ve used this trick often enough that it’s my hammer solution (so every problem is looking like a nail to me). ??

    Root

    (@root)

    I have got the greatest admiration for the php gurus who spend time helping people here. I always try the simple solution myself. Its usually all I can manage ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Separating Different Categories of Links’ is closed to new replies.