I used CPT UI to create customized publish varieties “Job Provides” which has a taxonomy with slug “job_offers_categories”.
Within the CPT Classes I’ve 4 classes:
- Alternate Programme
- Job Provide
- Job Request (Newbie)
- Job Request (Skilled)
What I need to obtain is to retrieve present publish class identify or slug
so I can assign completely different image in response to the class. So in my WP_Query I can retrieve present publish, however tried a number of methods to realize what I would like, however will not be working. Is both giving me Array
, undefined
or nothing in any respect like the instance beneath.
Right here is my code (instance of present publish: “Job Provide”):
$post_query = new WP_Query(array(
'writer' => get_current_user_id(),
'post_type' => 'job-offers'
));
whereas($post_query->have_posts()) {
$post_query->the_post();//GET POST OBJECT
$i = $post_query->current_post;//GET LOOP INDEX
$post_id = get_the_id();//GET POST ID
$view_post_URL = get_the_permalink();//URL FOR VIEW POST
$phrases = get_the_terms( $post_id, 'job_offer_categories' );
if ($phrases) {
foreach($phrases as $time period) {
echo $term->identify;
//Anticipated Consequence: "Job Provide" or "job-offer", choose to retrieve slug identify of customized class
}
}
}
Additionally tried the next which:
$the_cat = get_the_category( $i->ID );
echo $the_cat; // is returning `Array`
foreach($the_cat as $cat) {
echo $cat->identify; //Array to string conversion error
}