- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I have a custom post type named ‘tours’ and custom taxonomy named ‘tourtypes’ so i can categorize it into terms like ‘cultural tour’, ‘sports tour’ etc.
I do not know much about dealing with taxonomy. But I want to extend it so that instead of outputting all ‘tours’ post, user can also choose which tour category (term) they want.
in the theme template taxonomy-tourtypes.php this is part of the code to display the term title which work:
ID, ‘tourtypes’); foreach ($terms as $term) { ;?>
But when it comes to the part where i want to query the specified term it didnt work.
$paged = get_query_string_paged();
$counter = 1;
$termg = wp_get_post_terms($post->ID, ‘tourtypes’, array(“fields” => “all”));
$posts_per_page = get_option(‘theme_show_portfolio_items’);
if($posts_per_page == “”) {
$posts_per_page = get_option(‘posts_per_page’);
}
$paged = get_query_string_paged();
$counter = 1;
$termg = wp_get_post_terms($post->ID, ‘tourtypes’, array(“fields” => “all”));
$posts_per_page = get_option(‘theme_show_portfolio_items’);
if($posts_per_page == “”) {
$posts_per_page = get_option(‘posts_per_page’);
}
$my_query = new WP_Query(array(‘post_type’ => ‘tours’, ‘tourtypes’ =>’$termg’ ,’paged’ => $paged, ‘posts_per_page’ => $posts_per_page));
…
I manage to get it to work if i type in the term slug directly eg.
$my_query = new WP_Query(array(‘post_type’ => ‘tours’, ‘tourtypes’ =>’cultural’
…
I’m sure i just need a little change on the wp_query. Anyone care to point to the right code..i almost give up with this
anyone got any idea?