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
- Opinions and recommendations on the best barebones base theme [closed]
- How to insert a logo in the header?
- How to get category and archive title?
- Page template in two level deep folder
- Any official way to create an admin theme?
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Category Archive
- how to use a different domain/subdomain for authors/catagories on single site?
- How to get the url to tag & category base set by the user?
- How to list child categories in custom category template?
- Multiple level category drop-down
- One WordPress Install, Two Categories. Each Category Gets a Domain
- Remove “Parent” Selection When Adding/Editing Categories?
- Can I apply a WP theme to a specific custom page template?
- Theme Customizer not loading
- How to correctly add JQuery in a WP theme?
- What is the best way to handle multiple calls to get_template_directory_uri() and similar functions?
- Exclude category from Tag Template
- How to view WordPress’ default category IDs?
- Multiple Category Search
- Need Category RSS Feed that shows all posts
- How to customize category template?
- Category-slug.php not being used
- How would I go about adding custom header images per category?
- How to call custom category field data in theme?
- Limitations when modifying wp_title with a filter
- one category template for multiple categories
- Display posts separated by Category in Author’s page
- How to edit theme functions file to modify pagination?
- Move default page templates to sub directory
- Updating category template to change how subcategories display
- How can I get categories IDs if multiple categories requested via URI?
- Category template to show different categories based on parent
- Inside a loop, how to change CSS class based on category name?
- Redirect to another page using contact form 7? [closed]
- How do I get the trackback count of a post in wordpress without writing an SQL query?
- Is it possible to remove from default category widget?
- Limit number of posts on a custom category template – breaking pagination
- How to add menù section to my WordPress template?
- Getting the category title / description returns first matching post?
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- searchform.php doesn’t work properly
- Customizer: get_preview_url() inside customize_save_after hook
- How to add custom meta box when you have a custom page template file
- Two Sections on Woocommerce Catergory Page [closed]
- How to use wp_list_categories with plugin category?
- New to WordPress – Read the Codex, Other Docs; Still Confused
- Add Date & Author Meta to Category Archive Page
- Theme modification for custom category menus
- Custom css per category and per single post belong in each category
- How to hide widget from certain category
- Category link redirect to custom template page instead of index.php?
- SQL query to get posts from multiple categories but not in a category
- wp_delete_term or wp_delete_category?
- Different header for each category
- How to custom category template based on category?
- separate posts to have (kind of) 2 blogs?
- Output Title of Post’s Current Category
- WooCommerce shared categories
- Can’t display posts by filtering categories using isotope.js
- Category page 404s on mobile but not desktop?
- How can I add category variable inside posts?
- Style a category page the same way as the homepage?
- Any way to permanently translate themes?
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Theme Dev | Convert Template to Theme
- Use different file includes for single.php
- Display Taxonomies in loop with template args
- Most efficient way to have 1 template for parent, 1 template for child categories?
- How to get multiple loop in category.php, my scripts becomes madness
- Custom built theme won’t filter categories
- Create a child Theme or custom Theme
- Template files not working for archives and categories
- WordPress 3.5 how to determine if user is on category listing or category edit screen?
- Display only one level subcategory in wordpress
- Get all first images of posts in same category
- Best practice to create required pages
- Is there a block to print post link standalone in a block theme?