You can do something like this
global $post;
//Get the page name
$term = get_post( $post )->post_name;
//If a category with the same name exists, then show the posts from that category
if( term_exists( $term, 'category') )
{
//Show posts from $term category
}
I hope you get the idea. You can modify it any way to suit your need.
Related Posts:
- Are Category or Tag Archive Pages Possible?
- Category link redirect to custom template page instead of index.php?
- How to redirect to category page if page does not exists?
- Detecting top parent category fails on home page
- Could not insert term into the database
- Activate Gutenberg in category-descriptions
- How to show subcategories in categories else show posts
- How can I get category ID by category name?
- How would I increase the Author Role to be able to add a new category?
- How to remove the parentheses from the category widget
- Randomise results from a category page?
- Adding Custom User Profile data based upon Categories
- Only show category to certain user levels without plugin
- How to: 301 Redirect /category/ to /customname/
- Custom Query to search through categories
- Order posts by category name
- How can I make wp_list_categories output li with category-slug as class, for its children?
- Get sticky post from category?
- Display one latest post from multiple categories
- Archive pagination causing 404 with permalinks structure
- Remove word “Category” from WooCommerce product page [closed]
- Get a list of Terms for a specific category
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- How Do I Merge Categories With phpMyAdmin
- Display name of the last child category
- Edit the markup of categories list
- Show category children, one level
- If in category to be inside of a function
- How to exclude posts from a category when using this particular format
- Viewing category pages without the word ‘category’ in URL
- How to view WordPress’ default category IDs?
- Random taxonomy category list
- how to change template?
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Product Category WooCommerce
- Show all posts for a specific category/author
- Hard coded main navigation
- Resort get_categories
- one category template for multiple categories
- Display posts separated by Category in Author’s page
- One Specific Category To Permalink
- How can I define a custom archive for childs of a specific category?
- The arrangement of categories always change while posting article
- Woocommerce custom category page with pagination [closed]
- List posts in alphabetical order
- Categories list loop – add separator every 3 categories [closed]
- wp_list_pages() exclude category
- Limit categories and it’s subcategories for specific group of users
- Get the ID of 10 Latest Pages stored in a WordPress Category
- Admin: Navigation Menus do not show empty categories/taxonomies in the list’s search tab
- getting post data in functions.php
- Category specific order
- How can i remove the posts category class names from body_class
- Different Category Headers using in_category and elseif
- Remove the number of posts displayed in wp_list_categories()
- Problems with my conditionals in single.php by category
- WP_safe_redirect not working
- Do not show sub categories in the loop on archive-product.php
- related articles using shortcodes
- “Virtual category page” based on a custom field filter
- Show category meta in loop on homepage
- How to get selected taxonomy or category ID if using custom walker?
- Show Secondary Sidebar on Category pages (archive)
- Get categories of queried posts
- Limit Loop to One Category
- wordpress taxonomy query posts
- Get post content intro text on category.php?
- Conditional category query breaking?
- Different header for each category
- Unable to browser posts in categories
- 3.1 post formats and specific categories/custom taxonomies
- sidebar troubles, taxonomy trouble
- Code for Category, Tags, Archive URLs
- Duplicate new categories across multisite network
- Display all subcategories from parent category
- Template category.php with page (no posts)
- How to show WooCommerce Categories on ‘shop’ page instead of products?
- How to list all subcategories from all categories but not from a certain category
- How to create Child Category page from scratch at wordpress?
- Automatically create tags and merge with categories
- How to insert category to post via php?
- How to set featured image as background for a specific category?
- Show Subcategory Name Instead of Parent Category
- Get category id of next / prev post inside the_post_navigation
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Adding relevant categories to related post
- Code to display category-specific single.php is overriding normal single.php, too
- Media Library filter returns undefined function get_current_screen
- Custom built theme won’t filter categories
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- get IDs from links categories
- Display all subcategories for a product category in woocommerce
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- How to control order when displaying child categories
- Why does my WordPress index has a category?
- How to get specific number of category post on a page or category page?
- Use same wordpress category base and tags as the prefix as the post permalink
- Display different sidebar based on search results from one category
- Adding category to existing post (uploaded file)
- how to create a page that shows all of multiple category posts on a single page
- Quick Edit on taxonomy names results in error