• raquelxmoss

    (@raquelxmoss)


    Hi All,

    I’m trying to make a list of categories within my custom taxonomy. So far I have it nearly working, but I can’t get the links to each category to work.

    I used this page as a starting point, but the links didn’t work even when I copied that code exactly.

    I suspect the problem is that I’m listing a custom taxonomy rather than categories, but I don’t know how to fix it. Any help much appreciated!

    Thanks ??

    ` <?php

    $args = array(
    ‘orderby’ => ‘latest_post’,
    ‘taxonomy’ => ‘interface_issues’,
    );
    $categories = get_categories($args);
    foreach($categories as $category) {
    echo ‘<hr />’;
    echo ‘<h2>
    <a href=”‘ . get_category_link( $category->term_id ) . ‘ title=”‘ . sprintf( __( “View all articles in %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.'</a>
    </h2> ‘;

    echo $category->description ;

    echo ‘<p><a class=”btn btn-default btn-lighter” href=”‘. get_category_link( $category->term_id ) .'” title=”‘ . sprintf( __( “View all articles in %s” ), $category->name ) . ‘”>Read all articles<i class=”fa fa-angle-right”></i></a></p>’;
    }
    ?> `

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    (@alchymyth)

    Thread Starter raquelxmoss

    (@raquelxmoss)

    Thanks alchymyth. Are you able to suggest more specifically what the code should be? I’ll have a play around, but I’m not great at this sort of thing.

    Michael

    (@alchymyth)

    for example, change this line:

    <a href="' . get_category_link( $category->term_id ) . ' title="' . sprintf( __( "View all articles in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>

    to:

    <a href="' . get_term_link( $category->term_id,  'interface_issues' ) . ' title="' . sprintf( __( "View all articles in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get_category – help with linking to each category’ is closed to new replies.