You need get_categories()
with an include
argument:
if (isset($_GET['cat'])) {
$this_category = get_categories(
array(
'include' => $_GET['cat']
)
);
var_dump($this_category);
}
You will get an array
of stdClass
objects containing category data. There are several ways to parse that but this might do:
if (isset($_GET['cat'])) {
$this_category = get_categories(
array(
'include' => $_GET['cat']
)
);
// var_dump($this_category);
$cats = wp_list_pluck($this_category,'slug');
var_dump($cats);
$needle = array('groups-london','groups-cambridge');
var_dump(array_intersect($needle,$cats));
if(array_intersect($needle,$cats)){
include(TEMPLATEPATH.'/groups.php');
}else{
include(TEMPLATEPATH.'/general.php');
}
}
Related Posts:
- Set a them for all subset of category
- Display random categories on the front page (Finding and Editing Theme Functions)
- Create single.php for specific category by category id
- is_archive() content being shown instead of is_category()
- Apply custom category template to subcategories
- Edit the markup of categories list
- How to add “Read More…” link in twentytwenty
- How to get data about category in category.php
- editing fonts of category links from the_category() funtion
- How to check category of of custom post type or not
- Different templates for different category tags
- Create theme for mobile phones and tablets only?
- Theme for subcategories
- I would like to feature a tip on the homepage
- How to add icon over specific thumb
- How to differentiate the homepage structure from the category page structure in WordPress template?
- How to list posts from a sub-category that is listed in a parent category (more details below)?
- Category custom template is not showing correct posts
- Choosing different templates for categories
- Getting page/category content to show up in my custom page template
- If it is a top level category show children otherwise show sibling categories
- altering theme – content generated by PAGES not PORTFOLIO
- Different header for each category
- How to detect /category and /tag base pages?
- Custom Portfolio Page
- Category Template – Show Last Entry as Featured
- Custom post type archive category page results in 404
- Last x Posted Categories?
- I need advice on how to structure the categories according to the layout i have
- show only sub categories if available?
- Include home page template in specific category template
- How to add meta description, keywords, custom title to a category template
- How to custom category template based on category?
- separate posts to have (kind of) 2 blogs?
- List categories of a post hierarchically?
- Output Title of Post’s Current Category
- Showing different posts on category pages
- Displaying categories in different template problem
- WooCommerce shared categories
- Include last post date in get_categories loop
- Show the number of the post
- How can i add service category here? [duplicate]
- How do I remove “Uncategorized” from my theme on my posts page?
- Products category search not working
- WordPress hierarchy clarification, does post_type_archive take precedence over taxonomy-term archive?
- In if…else condition, the else statement shows even if if statement is correct
- Can’t display posts by filtering categories using isotope.js
- Category page 404s on mobile but not desktop?
- Regarding Tags And Categories
- How can I add category variable inside posts?
- problem with filter of custom portfolio categories
- Deleted categories still listed until additional page refresh
- Custom Archive Template for Multiple Categories
- Is hand coding required at all?
- How to show some of category in wordpress
- How can I make a category function as a page?
- How do I target this page specifically?
- Search Replace Database ONLY for posts of certain category?
- Default URL for category dropdown select option
- Media Library Categories
- Filter custom taxonomy posts via AJAX
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Style a category page the same way as the homepage?
- Need help to structure our a complex hierarchy
- Adding a category view to a page
- How to dowload and edit content of a website
- Using a template page parent breaks page
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Any way to permanently translate themes?
- Change single.php template based on parent category
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Use another theme template in my theme
- Theme Dev | Convert Template to Theme
- the_content() not showing full posts in category template
- Managing Custom Designed Content
- Jetpack Mobile Theme: when on smartphone on categories the theme suddenly changes to jetpack mobile theme even though it’s deactivated
- Use different file includes for single.php
- Inserting categories as a hierarchical terms from frontend form
- Display Taxonomies in loop with template args
- How to prevent XSS attack in wordpress theme?
- How to add a post with new Taxonomy without assigning to default category?
- Best strategy for providing theme options using customizer
- How do you add Author and date Published on Category Pages?
- Lowest catagory link
- Removing categories, Comments etc from posts?
- Most efficient way to have 1 template for parent, 1 template for child categories?
- Include category name in page template
- Category Templates for Post Types not Working
- Own Custom Tags/Category page ( posts)
- Gettind 404 not found wen click the view button for a given category custom post type portfolio
- How to create default categories in new installs?
- How Does One Create a Global Variable Repository
- Having some trouble properly displaying Custom Post Types in templates
- How to get multiple loop in category.php, my scripts becomes madness
- One category not displaying template updates
- Category base 404 – fix
- Category page with gallery for each post
- display certain category on custom template page
- Custom built theme won’t filter categories
- WordPress a template for subcategories fo a given category, but not for root category