WordPress: Taxonomy archives based on Custom Post Type -
i've generated 3 different custom post types (e.g. books, movies, games). , i've custom taxonomy of them (e.g. genre).
what need archives taxanomy based on post types. example: "books-genre", "movies-genre"...
is there solution that? i've taxonomy archive "genre".
the way approach custom post archives create custom archive template wp_query
sections need them. you'd create blank file in root of theme @ archive-cptnamehere.php
.
you might have template partials add in core of page looks this:
<?php // 1- id of page's path url (reliable) $pagepath = $_server['request_uri']; $pageobject = get_page_by_path($pagepath); $pagepathid = $pageobject->id; // 2- print page title $teampagetitle = get_the_title($pagepathid); echo $teampagetitle; // 3 - query gets data need // args: -1 shows locations, orders locations alphabetically title, orders locations a-z, query against team items $args = array( 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'asc', 'post_type' => 'team', 'meta_query' => array( array( 'key' => 'team_page_categorization', 'value' => $team_page_categorization_options_array_item, 'compare' => 'like' ) ) ); $the_query = new wp_query( $args ); // 4- setup query while loop if($the_query->have_posts()) { while($the_query->have_posts()) { $the_query->the_post(); // 5- need inside loop // 6- close up, don't forget reset_postdata can additional queries if necessary! } wp_reset_postdata(); } ?>
Comments
Post a Comment