Well, considering the archive page you’re wanting is custom made, you’re going to have to print the directors list yourself and add in the link to your custom archive page.
First, you need to decide what you want the URL to be for the movies archive page filtered by director. But, for this example, let’s say your movies archive page is http://mywebsite.com/movies/ and you want your movies-director archive page to be http://mywebsite.com/movies/director/woody-allen. Here’s what you do:
Using the code on Custom CPT-onomy Archive Pages, add a rewrite rule to create your custom archive page. This will probably go in your functions.php file.
add_action( 'init', 'my_website_add_rewrite_rule' );
function my_website_add_rewrite_rule() {
// allows our query to pick up the director slug
add_rewrite_rule( '^movies/director/([^/]*)/?', 'index.php?post_type=movies&directors=$matches[1]&cpt_onomy_archive=1', 'top' );
}
Now all you need to do is print the list.
// first, retrieve the directors terms
if ( ( $directors = get_terms( 'directors' ) ) && !is_wp_error( $directors ) ) {
?><ul><?php
// print each director with your custom link
foreach ( $directors as $director ) {
?><li><a href="<?php echo get_post_type_archive_link( $post_type ); ?>director/<?php echo $director->slug; ?>"><?php echo $director->name; ?></a></li><?php
}
?></ul><?php
}
Was that helpful?
Spot on! I’m proud that I got close, with a lot more code, but close. Your code is so much better! 😛 Thanks for all your help Rachel! unreal!
Good deal! Glad I could help!