Include/Exclude posts by tag name ?
-
Have a function to include only posts with a certain tag id (say 21) on the home page.
`function onlyinclude_tag($query) {
if ( $query->is_home) {
$query-> set(‘tag__in’,array(21));
}
return $query;
}
add_filter(‘pre_get_posts’,’onlyinclude_tag’);`Would prefer if I could include by tag name instead tag id !
Any help much appreciated.
I think i am looking for something to identify the tag id from the name (could be wrong) like say
$tag_id = get_tag_ID('the name');
—–> made up –> but i’m looking for something like it ??obviously there may be a simpler way!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Include/Exclude posts by tag name ?’ is closed to new replies.