How to check if a word is in the category slug?
-
I want to make categories have different templates if the have a certain word in their slug. For example, all categories with the word “computers” will have one template. All categories with the word “videos” will have another template. So, the structure will go something like this:
if (category slug has word videos)
// use this templateelseif (category slug has word computers)
// use this templateI found this code to get the category slug (haven’t tested it)
<?php if(is_category()) { $cat = get_query_var('cat'); $yourcat = get_category($cat); $cat_slug = $yourcat->slug; ?>
but then I don’t have enough php knowledge to see if a word is in that category slug. Please help. Thank You.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to check if a word is in the category slug?’ is closed to new replies.