I’m a sucker for regular expressions:
<?php
$category = 'test-category';
$category = preg_replace('/-/', ' ', $category);
$category = ucwords($category);
echo $category;
Related Posts:
- Allow two posts (from different categories) to have the same slug
- Put a link to a category round a hard coded A HREF
- Get posts with at least one category in common with current post?
- What is an equivalent of single_cat_title for getting the slug of the category?
- Redirect to another page using contact form 7? [closed]
- Rewrite rule not working, but only when parameter is text
- Hide a specific category title from displaying on site
- Exclude a category slug on pagination
- WordPress using get_term to retreive slug not working as expected
- get_category only returning details for ‘uncategorized’
- Remove /category/ from category (archive) page URLs (without using a plugin)
- Create a custom plugin with dynamic child pages listing database records
- Custom plugin with dynamic child pages listing database records
- Issue adding sub category programmatically
- What query string parameter is available for index.php, that works for both pages and blog articles?
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- php script to change slug in post automatically
- how do I get a specific post from a post with a subcategory in WP
- WP grandchild categories in nested ul li
- Grab posts by multiple categories
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to show single category archive
- Dynamic content based on a URL parameter
- Move category description below post list in blog
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Colon is Missing In My Website Url in WordPress
- Get page that displays all children of taxonomy parent
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to use $_GET function WordPress backend
- selected option if current category is the value
- get_template_part based upon post’s category
- how to save selected option in variable for rest api category filter
- Extend PHP regex to cover “srcset” and “style” attributes
- Setting default category base on theme activation
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Different post styles depending on category
- Display category name only once inside loop
- My php header() function is not working [closed]
- Scrape external webpage for first image and add it to new post
- Create custom permalinks to show Custom Post Type’s relationship?
- Search Query: how to construct a search string from two select elements?
- How to show only subcategories in parent category not parent category?
- Get URL Parameters from referer
- Need help enqueueing webfonts
- how to show only specific category for a template
- Dilemma of Populating all the categories in a drop down list
- Display most popular posts of category
- Creating sub-categories via php
- Define specific category name in PHP
- Why is $wp->request empty in WordPress 6.0?
- Get the URL of the page from which an ajax request has been launched within ajax callback
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- How to check if the current page is at a specified path in the URL?
- List taxonomy term slugs within shortcode (do_shortcode)
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- How to array only one key from another array
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- How to pass a PHP $_GET variable and fetch/output it?
- Get all categories post is not in
- Get latest post from all categories except one
- Displaying posts based on category
- Post’s ID pattern?
- How do I remove a category from a wordpress loop>
- Get categories names as an array to use it in theme settings
- How do I add a tag slug to a category URL to filter posts?
- Change of category structure will cause two kinds of URLs for one post
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- How to get the last category name of a child category?
- page-slug.php not working but only for specific slug
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- Use get() method to grab all categories and output inside another method
- Only show size attributes in product box woocommerce when available
- How to get category name or ID by post?
- Custom post type category not displaying category ID
- Argument for if term-> have child?
- How to get current post category details inside “loop”?
- How to separate categories with commas?
- How to hide posts of a specific custom category in WordPress?
- Show all tags within a category?
- Post not populating for custom post type based on category selection
- Add new post in existing categories using wp_insert_post
- I’m unable to call img path using single quotes in an array?
- How to change logo by category
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- Problem with custom loop and wp_list_pluck [closed]
- Listing titles and custom fields of entries within subcategories
- Remove slugs from custom posts type
- random display categories – change url
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- Alphabetically Ordered Category in WordPress
- change default RSS feed URL