I am using custom taxonomies.
How to check if current page has tag_ID = "XXX"
?
If that is any help the URL form WordPress admin looks like this:
http://localhost/website/wp-admin/edit-tags.php?action=edit&taxonomy=company&tag_ID=13&post_type=news
Update. Here is code which I’m currently using. Does not work.
<?php
function insert_news($company = 0)
{
global $post;
$count = 0;
$news_query = new WP_Query(array(
'post_type' => 'news',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'ASC',
'company' => $company
));
$total_count = $news_query->post_count;
while ($news_query->have_posts()):
$news_query->the_post();
$count++;
$tag_id = get_query_var('tag_id');
if ($tag_id && $tag_id == '14') {
// ID 14
} else if ($tag_id && $tag_id == '13') {
// ID 13
} else if ($tag_id && $tag_id == '12') {
// ID 12
}
endwhile;
}
?>
6 s
All the tags is inside the query, it is possible to check for this via get_query_var(); all objects inside the query.
For the tag ID ask with this code: get_query_var( 'tag_ID' );
Also it is possible to check for tags, like get_query_var( 'term' )
and the taxonomy get_query_var( 'taxonomy' )
So you can create an Loop with your tag data form your taxonomy; like
$wpq = array (
'post_type' => 'post',
'post_status' => 'published',
'taxonomy'=> get_query_var( 'taxonomy' ),
'term'=> get_query_var( 'term' )
);
$query = new WP_Query( $wpq );
while ( $query->have_posts() ) : $query->the_post();
So you can check:
if ( 'your_tad_id
=== get_query_var( ‘tag_ID’ ) ) `
- An hint; if you will use the check via
$_REQUEST
-var; please filter this data or use only for if statements.