• Resolved hamburger

    (@hamburger)


    <a href="<?php echo $category_link; ?>">< Return to <?php foreach((get_the_category()) as $category) { $category->cat_name . ' '; } ?>
    <?php echo $category->cat_name ?> Projects</a>

    This code works differently between browsers? Firefox and Chrome are wrong but Internet explorer gets it right!

Viewing 5 replies - 1 through 5 (of 5 total)
  • can you post a link to your site, pointing to this link?

    what is ‘are wrong’ and ‘gets it right’ in understandable terms?

    Thread Starter hamburger

    (@hamburger)

    Hi Alchymth, Thanks for the reply.

    Here’s a link to the site I’m working on:

    http://www.mayrussell.com.au/projects/institutional/the-australian-national-university-wes-whitten-building

    At the bottom of the page there is a “Return to Institutional Projects” link. It is generated by the above code.

    When using Firefox and Chrome the link just links to the current page. However in Internet Explorer 8 the link correctly links back the the category page.

    Just wondering if it is a bug or terrible coding?

    Thread Starter hamburger

    (@hamburger)

    This code from Help is also busted :

    <?php
        // Get the ID of a given category
        $category_id = get_cat_ID( 'Category Name' );
    
        // Get the URL of this category
        $category_link = get_category_link( $category_id );
    ?>
    
    <!-- Print a link to this category -->
    <a>" title="Category Name">Category Name</a>

    As it just redirects to the current page, not the Category in Chrome and Firefox. Internet Explorer correctly generates the link however it won’t work if you middle click the link

    My permalinks looks like this if it helps:

    /projects/%category%/%postname%

    Thread Starter hamburger

    (@hamburger)

    Okay, so in the permalinks structure adding a “/” to the end of the permalinks fixes the discrepancies between the browsers.

    Hwoever the problem still remains of the link linking to the page itself not the category!

    Thread Starter hamburger

    (@hamburger)

    For anyone else struggling with this:

    <?php
    foreach((get_the_category()) as $link) {
        echo '<a href="../"> < Return To '.($link->name).' Projects</a>';
    }
    ?>

    This worked in the end. Simple and avoids WordPress’ terrible way of handling and linking categories.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Category link bug between browsers’ is closed to new replies.