You can do something like this:
<a href="https://wordpress.stackexchange.com/questions/80014/<?php echo get_post_type( $post->ID ); ?>" class="<?php echo str_replace(' ', '-', get_post_type( $post->ID )); ?>">
<?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type->label ; ?>
</a>
and in your CSS part you can do something like:
.pretty-little-liars
{
background color: khaki;
}
.once-upon-a-time
{
background color: blue;
}
Related Posts:
- Style custom columns in admin panels (especially to adjust column cell widths)
- get post type plural
- How to add a CSS class to every image in a Custom Post Type
- CSS for Custom Post Types
- Is it possible to insert text into an html tag using functions.php?
- How do you use JavaScript to detect the homepage
- Custom Post Type and taxonomies’s labels localization not working
- How can I use a different default admin menu icon for custom post type?
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- different template for first and second level custom post page
- Change post featured image on hover
- Custom post type and body_class: Remove “blog” class
- Is possible add class for last post of Custom Post Type?
- Customize my custom taxonomy table in Admin panel
- How to Create Columns with WordPress and CPTUI display page ?
- Custom Post Types — $args vs. labels array
- Add custom CSS class to custom post type
- Change “empty trash” button text?
- Displaying custom post types as a gallery
- Trying to add a class to post links
- One Site. One Theme. Multiple Stylesheets without plugins?
- Posts are not rendering perfectly [closed]
- Questions regarding add_meta_box()
- Multiple Stylesheets For Post and post type?
- Use conditionals with wp_enqueue_style to attach stylesheet according to post type displayed
- DIVI Theme customizer changes not applied on existing pages and designs are not shown on the front
- Custom post type not pulling CSS
- Is it possible to link an external stylesheet, exclusively within a specific single post template?
- Displaying image instead of post label in wordpress
- Changing menu label to post name for custom post type
- Change Background Color For CPT Template
- Can’t open Custom Post Types Link in navigation
- Multiple search template with separate stylesheets
- Multiple Block Quotes without using HTML
- How to insert post into a page?
- Woocommerce product page is not showing custom css [closed]
- WordPress custom post type odd and even styling [duplicate]
- How do I target a links only in a custom post type and only in the p tag?
- Add a background image into a post [closed]
- how to display custom taxonomies in front page
- Pull total post count for child category and parent if term ID
- Customize Custom Post Type URL
- What’s the WP way to load remaining custom posts?
- Show image gallery from a custom field
- WooCommerce sort products by the actual product width(not the shipping width)
- Manage custom post type in woocommerce /my-account/ page
- How to rewrite url for any specific taxonomy?
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Permit users with author role to edit a custom post type
- Specific query for custom post type
- wp_get_archives() not working for my custom post type
- Able to edit custom post, but unable to create new custom post when within submenu. What capability is missing?
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- Custom post URL 404 error
- Show child custom post types list inside single parent custom post type
- Add Custom Post Type as top level menu item for a custom page
- Custom Post Type Video – Online/Offline
- customise template to only show custom post type entries
- Programmatically rewriting slug through functions.php but returns 404
- limit value taxonomy based on previous taxonomy value wordpress
- Dynamic dropdown select values depending on other custom field value
- Allow Static Page Load Dynamic Child Pages
- How to change the post type a theme shows by default?
- Exporting individual custom post type post for deployment?
- Why is this query not working? (Standard posts + custom post type)
- Get unique superset of taxonomy terms from a list of custom posts in another hierarchical taxonomy
- How to render a custom post type template with custom fields using shortcode
- Create a custom php page and load it at a specific slug
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Structure of data : CPT + terms
- How do you paginate a query grouped by month?
- Disable saving posts as draft (make all posts mandatory regardless of the post status)
- Grouping metadatas into one
- How to handle a CSV with 65,000+ rows and make it searchable?
- How to create custom post type with custom taxonomy?
- URL rewrite add author as base
- current post index within content.php
- Create custom post type (using pods) then convert existing pages to custom post type?
- Custom Post Type with Same Page URL
- Remove CPT name from permalink but add %category% instead
- page menu entry for custom post type
- Exclude objects from WordPress API based from ACF field using rest_prepare_{$post_type}
- Limit number of custom posts per taxonomy
- Tracking changes in admin-page so user gets warning when leaving the page
- Custom taxonomies relationship
- filter custom post in rest api with custom function
- Get Posts by multiple custom fields is not working
- How to change wp prefix for custom post type only?
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- create a new page from a custom post type similar to an authors page
- I want to change the word “Tags” in WordPress to something else, but how?
- How to handle paged param in post and custom-post-type?
- Set a checkmark in a category based on a URL-parameter
- CPT archive admin menu label
- Anon function and add_meta_box
- Permalinks /country/city/cpt/postname/
- Custom Permalink to remove category word , keeping posts permalink with date?
- Custom post type ‘articles’ ignores posts_per_page, reserved post_type?
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- Several post types on WP Query by tag and taxonomy