Blog tag and category links on single post page

  • I have post tag links at the bottom of each blog post, and in the sidebar I have widgets with lists of blog categories and blog tags.

    The links for the category and tag lists in the sidebar work fine on the blog post list page (index.php) and the archive page.

    For example:

    On the single post page, however, they appear to be relative to the post URL.


    Code for category list widget:

    1. <perch:before>
    2. <h3 class="widget-title">Categories</h3>
    3. <ul>
    4. </perch:before>
    5. <li><a href="archive.php?cat=<perch:category id="catSlug" />"><perch:category id="catTitle" /> <span>(<perch:category id="" when-empty="0" />)</span></a></li>
    6. <perch:after></ul></perch:after>

    And code for tag list widget:

    1. <perch:before>
    2. <h3 class="widget-title ">Tags</h3>
    3. <div class="tagcloud">
    4. </perch:before>
    5. <a href="archive.php?tag=<perch:blog id="tagSlug" />" rel="tag"><perch:blog id="tagTitle" /></a>
    6. <perch:after></div></perch:after>

    Please let me know if there is any other info you need to help me figure this out. Thank you.

  • drewm

    Approved the thread.
  • Your link is relative, meaning that the link will use the current page as its starting point.

    If you start your link with a forward slash <a href="/ then link will use the site's root as its starting point.

    So if you start your link with <a href="/blog/ then the link will always point to the blog folder, which is where your archive page is located.

  • I thought I tried that already but I just set it for <a href="/blog/ and that worked. I have another site on the same server with the exact same setup and version, but didn't need to add the /blog/ with that one...weird.