• Resolved KTS915

    (@kts915)


    This is my first time using CPT-onomies, and I might be in over my head!

    I have two custom post types: ‘instructor’ and ‘unit’. I have made them into CPT-onomies and associated them with each other. This works beautifully.

    I also have a custom taxonomy: ‘course’. This acts like a category for the CPT ‘unit’. That works fine too.

    Here are my two questions.

    1. I would like to have the name of a unit instructor show on that unit’s post, and hyperlink back to the instructor’s own post. Adapting what I found from this thread, this is what I have so far:

    <?php
    global $cpt_onomy;
    $instructor_list = get_the_terms( $post->ID, 'instructor' );
    if ( $instructor_list && ! is_wp_error( $instructor_list ) ) {
        foreach ( $instructor_list as $term ) { ?>
        <span class="instructor">Instructor: <a href="<?php $term->name; ?>"><?php echo $term->name; ?></a></span><?php
    }
    }
    ?>

    This works well, except for the hyperlink. I tried various adaptations of the hyperlink from the thread to which I linked, but I couldn’t get any of them to work.

    Do you have any suggestions, please?

    2. I would like to have a list of all the instructors for each of the units within a course display on the course archive page (ideally, with each one hyperlinked too). Do you have any suggestion as to how I might achieve that?

    https://ww.wp.xz.cn/plugins/cpt-onomies/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter KTS915

    (@kts915)

    OK. Worked it out now!

    Grey Man

    (@christopher-greenhough)

    Would you mind posting your solution if you have time? Nothing worse than visiting a forum and finding someone has solved their own problem but doesn’t explain how : )

    Thread Starter KTS915

    (@kts915)

    Nothing worse than visiting a forum and finding someone has solved their own problem but doesn’t explain how

    Nothing worse?! Wow!

    Anyway, this is what I have:

    <?php
    global $cpt_onomy;
    $instructor_list = get_the_terms( $post->ID, 'instructor' );
    if ( $instructor_list && ! is_wp_error( $instructor_list ) ) {
        foreach ( $instructor_list as $term ) { ?>
        <h4 class=instructor_list><span class="instructor">Instructor:</span> <a href="~/blog/instructor/<?php echo $term->slug; ?>"><?php echo $term->name; ?></a></h4><?php
    	}
    }
    ?>

    I hope it helps!

    Nothing worse?! Wow!

    How about, Quite frustrating!

    Most likely if you have an error/bug caused by a plugin or code you use, it will crop up again.

    If you have figured out a solution why not share for the benefit of the community?

    Thread Starter KTS915

    (@kts915)

    In an active forum, I always do. (You can check easily.) In this case I wanted to see how active this forum is, because that helps me judge how useful and/or well-used the plugin is (and therefore how likely I am to get help if I continue to use it).

    It’s taken three months to produce a response. So now I know.

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

The topic ‘Hyperlinks’ is closed to new replies.