Here it how you can do it.
$tag = 'medical & health';
$tag_class = preg_replace('/[^A-Za-z0-9-]+/', '-', html_entity_decode($tag));
echo '<li><a class="'.$tag_class.'" href="https://wordpress.stackexchange.com/questions/108491/javascript:void(0)">' .$tag. '.</a></li>';
Related Posts:
- tag.php doesn’t work with tags on a custom post type post?
- How can I include custom post types on a tag page?
- Taxonomy count per Post type
- Load custom posts with same tag as page
- post_tag taxonomy with custom post type
- Tag list & tag index for custom post type
- Undefined property: stdClass::$labels in general-template.php post_type_archive_title()
- Find callback function for custom taxonomy metabox
- Get posts with tag all post types
- Search Custom Post Type with all meta attached?
- Show certain terms from custom taxonomy but exclude ‘parent’ terms?
- Exclude Custom Post Type & Pages From Auto-Tag Function
- Tag.php not displaying posts with the tag
- Registering tags taxonomy for a custom post type
- Query for custom posts with a specific tag slug
- Categories and Tags not working!
- associate custom post type with tags with specific pages
- Is it possible to make tag archive page specific to Custom Post Type?
- Search doesn’t find tags or categories in custom post types
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- Navigation menus not showing because of custom post type filter
- Where to store custom tagging data associated with a custom post type
- Can custom taxonomies items have attached properties?
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- Does anyone have a plugin that could automatically tag custom post types in wordpress?
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- Group posts by custom post type
- Tag page with Custom Post Types not returning any posts
- Custom post types and tag archive pages/permalink structure issue
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- search also in taxonomy, tags and custom fields
- Listing tags from a custom post type
- wp_update_term_count_now doesn’t work with a custom post type?
- Add tag to a custom post type doesn’t change the total of custom post type in backend
- Custom Tag Description unable to display just below and outside of the Loop
- Cross reference custom post types
- How to get all tags of a custom post type by id
- How can I show 1 featured post in a styled element, and the next few below differently styled
- Show all tags on custom post type
- Best way to specify “article type” in URL
- data-type=”” … needed post tags stripped of characters
- Dynamically output a class to an anchor tag depending on what tag is chosen
- Creating tags via API
- Meta data (Tags and Categories) for Custom Posts not showing.
- get_the_tag_list() returns bad links
- How to list tags from custom post type attachments?
- portfolio custom type tags support
- How can I create an automatic drop down menu with my tags?
- Need help deciding on a taxonomy
- display custom taxonomies limited to custom post type?
- Get Posts by Category, Tag , and CPT Taxonomy
- WordPress admin display post type tags as checkbox
- The Difference Between Categories and Tags and Taxonomies and Terms
- Show all Tags in each post
- wp_get_canonical_url showing first url of the post for custom page
- Print all the tags from a custom post type
- How to constrain the results to a specific post_type on tag archive page?
- Default post_tag for custom post type
- Custom posts – tag pagination
- add custom tags for custom post type in wordpress
- How to Display the tag content of Custom Post?
- Issue with Custom Post Type Tags
- Custom post type, taxonomy and admin bar
- display custom portfolio tags
- Advanced archive url structure (category, tag and date)
- Tag template not returning posts [closed]
- One post auto attached to many another items
- Navigate by Tags inside a custom Post Type
- Why doesnt my tag page populate with this custom post type?
- Search CPT by tag ids
- get taxonomies from terms
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- Tags being removed upon updates to related posts: ACF/Genesis/WP5.4.1
- CPT tags not showing when editing post
- How to convert Post Object Custom Field into Tags
- How to add independent “Tags” to Custom Post Type?
- Custom Post didn’t display on tags page
- Rewrite url post_tag for custom post type
- Add tags to a “pending” post before publishing
- Custom Post Type tag taxonomy “Page Not Found”
- Do not output category and tag URLs
- Custom post tag images not displaying with ACF
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- Filter custom post type by tags
- Default taxonomy ‘post_tag’ added to CPT managing by custom role : nothing in the metabox
- Custom Post Type – Admin Columns
- Taxonomy count per Post type
- Archive.php is not displaying tags
- WordPress Custom Post Type and sort by Tags
- get tags from custom post type
- custom post type tags
- Query Custom Post Type by Tag
- Display by tag from different post types
- Tags and Taxonomy links not working for Custom Post Types
- Tag-post relationship problem
- Post type cloud like tag cloud?
- WordPress 3.1 – Tag page not showing posts from custom post type
- Attaching multiple custom taxonomies to one CPT?
- how insert how many post type in this function?
- Can WordPress show posts based on a button that the user clicked 2 pages back?