Title: Getting details
Last modified: July 27, 2019

---

# Getting details

 *  [Cezar Ayran](https://wordpress.org/support/users/ayrancd/)
 * (@ayrancd)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/getting-details/)
 * I have a post type called “lab” which has a taxonomy called “states”.
 * I added this plugin and created a new post called “careers” and added a CPT “
   lab” as its taxonomy.
 * So this is the order
 * States
    – Labs –Careers
 * **When I click on a state I get its slug and list all “Lab” now I need to get
   all Careers that I added to a lab**
 * How can I get it? I tried the code below:
 *     ```
       $args = array(
       	'post_type' => "careers",
       	'tax_query' => array(
       'taxonomy' => 'lab',
       	'field' => 'slug',
       	'terms' => 'global-pathology',
       									'include_children' => false
       	),
   
       	'posts_per_page' => -1,
             'orderby' => 'date',
       	 'order' => 'DESC');
       	$posts = get_posts($args);
       ```
   
 * But it’s not filtering by lab taxonomy
    -  This topic was modified 7 years, 2 months ago by [Cezar Ayran](https://wordpress.org/support/users/ayrancd/).

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

 *  Thread Starter [Cezar Ayran](https://wordpress.org/support/users/ayrancd/)
 * (@ayrancd)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/getting-details/#post-11773775)
 * I didn’t find a solution using WP functions so I had to use a regular select 
   using the code below:
 * **URL = state/florida/georgia….**
 *     ```
       <?php
       	$tax = get_categories(array('taxonomy' => 'category_lab', 'posts_per_page' => 1,  'hide_empty' => false, 'slug' => $_GET["url"], 'orderby' => 'name', 'order'   => 'ASC'));
       	if(count($tax) == 0){
       		$stateN = "Try again";
       	}
       	foreach($tax as $cat) {
       		$stateN = $cat->name;
       	}
       ?>
       <div class="col12 title">
       	<?=$stateN?>
       </div>
       <div class="col12">
       	<?
       	$argsP = array(
           'post_type' => 'lab',
           'tax_query' => array(
               array(
                 'taxonomy' => 'category_lab',
                 'field' => 'slug',
                 'terms' => $_GET["url"], 
                 'include_children' => false
               )
             ), 'hide_empty' => false, 'orderby' => 'post_title', 'order'   => 'ASC'
       	);
       	$postsPages = get_posts($argsP);
       	if(count($postsPages) == 0){
       		echo "No results found :(";
       	}
       	foreach($postsPages as $post): ?>
       	<b><?=$post->post_title; ?></b><br>
       	<?
       		$results = $wpdb->get_results("SELECT wp_posts.ID, wp_posts.post_title FROM <code>wp_postmeta</code> inner join wp_posts on wp_postmeta.post_id = wp_posts.ID where wp_postmeta.meta_key = '_custom_post_type_onomies_relationship' and wp_postmeta.meta_value = ".$post->ID." and wp_posts.post_type = 'careers' and wp_posts.post_status = 'publish' order by wp_posts.post_title ");
       		if(count($results) == 0){
       			echo "No results found";
       		}
       		foreach($results as $career){ ?>
       	<a href="<?php the_field("pdf", $career->ID)?>" class="linkCareer"><?=$career->post_title?></a>
       	<? } ?>
       	<br><br>
       	<? endforeach; ?>
       </div>
       ```
   
 *  [Tony G](https://wordpress.org/support/users/starbuck/)
 * (@starbuck)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/getting-details/#post-11880859)
 * Is the close brace on line 8 valid?

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

 The topic ‘Getting details’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/cpt-onomies_f2f2f2.svg)
 * [CPT-onomies: Using Custom Post Types as Taxonomies](https://wordpress.org/plugins/cpt-onomies/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cpt-onomies/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cpt-onomies/)
 * [Active Topics](https://wordpress.org/support/plugin/cpt-onomies/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cpt-onomies/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cpt-onomies/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Tony G](https://wordpress.org/support/users/starbuck/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/getting-details/#post-11880859)
 * Status: not resolved