Support » Fixing WordPress » use “php bloginfo” to get link to category

  • Resolved csleh


    I have a menu that links to category pages. Using list_categories works great, but on the home page each

    <li> has a different image. All this is working but now need to add the link on the home page to the category page.
    I’m hoping for something easy, like:

    I want to do this instead of hardcoding in the url, in case we make changes to the permalinks before the site goes live.

    SO — How/where can I find the info for base url?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Never mind, I was being a bit of an idiot. since each

  • gets its own class, I just need to add a different id to the home
      and style the links.
  • So:

    if (is_page(13)) {echo '<div id="mainnav"><ul id="homenav">';
            echo '</ul></div>';
    }  else {
           echo '<div id="mainnav"><ul>';
            echo '</ul></div>';

oops, still not thinking clearly. While the above works, it isn’t what I wanted. My code used a <div> after each opening
<li>, with the image set as a background. Using the code above puts the image behind the li. This doesn’t work because I’d have to add the background color to the image an adjust how the text lines up. Just messy.

Any idea how I can add a div to each line item?

sheesh. got it:

<div id="mainnav"><ul id="homenav">
  <li class="cat-item-3"><a href="/category/cat-name1/">
          <div class="class1"></div>category 1</a></li>
  <li class="cat-item-4"><a href="/category/cat-name2/">
          <div class="class2"></div>category 2</a></li>
  <li class="cat-item-5"><a href="/category/cat-name3/">
           <div class="class3"></div>category 3</a></li></ul>

It would be nice there was a way to add a span or div automatically with wp_list_categories because then if a category changes I wouldn’t have to edit the header file.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘use “php bloginfo” to get link to category’ is closed to new replies.