You can access the post type properties using get_post_type_object()
. The rewrite argument will be a property if the returned object:
$post_type_object = get_post_type_object( 'products' );
$rewrite_slug = $post_type_object->rewrite['slug'];
Update
I needed this for permalinks inside a template part where there are categories displayed.
No you don’t. To get the URL to a category archive, use get_term_link()
:
<a href="https://wordpress.stackexchange.com/questions/364027/<?php echo esc_url( get_term_link( $category ) ); ?>" class="cat-bar__label"><?php echo $category->name; ?></a>
Related Posts:
- How to customize a permalink (URL) structure?
- WordPress Custom Post Types with a page as a parent?
- Custom post status not working
- Get custom post type by category in a page template
- Redirect after deleting post and keep track of pagination
- Remove POST_TYPE from custom post type permalink
- Error after deleting Custom Post Type with a function (no trash used)
- Row actions not showing? Why?
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How do you output custom code between posts in the loop?
- How to append element after thumbnail
- Dynamic Custom Post Type Plugin
- Custom Post Type | Fatal Error on register_post_type()
- Weird problem happening with custom taxonmy when creating/updating posts
- Admin notice not displaying
- Plugin: register custom post types, child ready and performance best practices
- Use custom metabox to update automatically a post after a given date
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Problems wp_insert_post and save_posts filter
- Redirect to another page using contact form 7? [closed]
- Show current custom taxonomy
- How to insert data into meta box from another plugin?
- How exclude or skip post type with get_next_post_link
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- How do I add custom HTML to the content of an archive page’s posts?
- Creating a non-hierarchical Taxonomy that behaves like categories
- post_content is stripping HTML when adding a new post? [closed]
- Validate Custom Post Type fields
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Convert Custom Table Data Based Plugin To Be Searchable
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- How do I ensure that post_type and Taxonomy use the same slug?
- Custom post type page with parameter
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- How to show the post which checkbox is not selected
- Is it possible to get the specific content on the search page?
- Why is my custom post content only viewable when signed into WordPress?
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Plugin Development using classes – Public & Private Callbacks
- custom post type and user post count shortcode
- How to limit the number of custom posts certain users can publish in WordPress using php script?
- Having issue on Loading Meta Data From CSV to CPT
- Stored meta from attachment, video length?
- WordPress query posts by custom post type not workng
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Registering an optional custom post type from a plugin
- Add category slug as class attribute in a link array
- Add Excerpt On Quicksand Plugin
- Select Menu for Custom post Type does not save
- Multiple Block Quotes without using HTML
- How to apply order on custom taxonomy and custom meta key on custom post type
- Inserting two categories
- Set a Custom Post Type as a Homepage
- How to dynamically register custom post type
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Update post meta not working in transition_post_status
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Hide parent categories when clicked, and show it’s childs
- Custom Path/Folder behind a custom post type
- get_post_meta not working on publishing
- Time based access control of custom post types – what is good approach?
- creat filter with wp_query
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag
- How do I add a custom screen for a custom post type to be called from custom post row action?
- ACF field key/value to show on taxonomy list
- Show titles, date of all posts on single category page
- WordPress custom post type permalink rewrite shows page not found
- Using custom field content as expression in IF statement [closed]
- Addition of custom option panel crashes Media Library & Admin Area
- Can one create multiple Custom Post Types with a for loop?
- delete_published_posts does not work
- How to start a new post with custom Taxonomies already set?
- WooCommerce sort products by the actual product width(not the shipping width)
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Create a custom php page and load it at a specific slug
- Structure of data : CPT + terms
- How to handle paged param in post and custom-post-type?
- Custom Permalink to remove category word , keeping posts permalink with date?
- Default text in a specific post type, but not visible?
- Form action/link to render a plugin in WordPress front-end
- Update postmeta Parent when post_status child change
- How to display custom WP menus?
- What is the best practice for displaying my plugin content in themes?
- Categorize custom post type
- How to Create Columns with WordPress and CPTUI display page ?
- Custom post type archive page blank
- Add Custom Post type menu to another menu in specific location
- Set a CPT slug as a base name for all the taxonomies
- WP_Query custom post type query not showing the exact post type
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- WordPress custom post type split into pages
- How to add custom field to view-edit post type page
- Assign External Database Queries to Global Variables and Make Them Accessible
- Hide a widget inside a div on specific type of post
- How to use TinyMCE Editor for one of my custom post meta field?
- How to import a custom MySQL DB table into a WordPress custom post type
- Shortcode to display Staff post type based on Location post type and Specialty post type