• I’ve set up a custom post type (projects) with it’s own custom category taxonomy (project_cat), which is all working nicely and has it’s own template. The following code shows the latest post in this taxonomy, but instead of linking to the post using esc_url(the_permalink();, I want to to link to the taxonomy. Anyone know how I can do this?

    <?php
    				// Display a list of the most recent projects in Internal
    				$projects_query = new WP_Query( array(
    					'post_type' => 'projects',
    					'posts_per_page' => 1,
    					'tax_query' => array(
    						array(
    							'taxonomy' => 'project_cat',
    							'field' => 'slug',
    							'terms' => 'internal'
    						)
    					)
    				) );
    				if ( $projects_query->have_posts() ): ?>
    				<div class="gallery-item">
    					<?php while ( $projects_query->have_posts() ) : $projects_query->the_post(); ?>
    					<a href="<?php esc_url( the_permalink() ); ?>">
    						<?php the_post_thumbnail('thumbnail'); ?>
    						<span class="view-item">
    							<span class="view-item-text">
    								<h2>Internal Walls</h2>
    							</span>
    						</span>
    					</a>
    					<?php endwhile; wp_reset_postdata(); ?>
    				</div>
    				<?php endif; ?>

    Thanks.

  • The topic ‘How to get link to custom taxonomy’ is closed to new replies.