You could add a filter on post_type_link
, which allows modification of custom post type permalinks before they are output.
The filter passes the custom post object as the 2nd argument, so we can use that to get the ID and form the new permalink:
function wpd_list_pages_permalink_filter( $permalink, $page ){
return '#' . $page->ID;
}
Then you can add and remove the filter when using wp_list_pages
:
add_filter( 'post_type_link', 'wpd_list_pages_permalink_filter', 10, 2 );
wp_list_pages();
remove_filter( 'post_type_link', 'wpd_list_pages_permalink_filter', 10, 2 );
If your menu contained the built in page
post type, you would use the page_link
filter. Note in that case the 2nd argument is only the page’s ID, not the full page object like in the post_type_link
filter.
Related Posts:
- Display custom post type and custom fields within a Bootstrap Carousel
- Highlighting current item of custom post types’ sub pages, listed by wp_list_pages
- Is there a way to make a custom Page type?
- Getting Bootstrap accordion working in WordPress loop with custom post type (collapsing issue)
- Custom Post Type Name Causing Problem
- Hierarchical Custom Posts – Highlighting Current Post in Sub-Menu
- Adding class to featured image
- wordpress wp_list_pages help
- Isotope Filtering with Bootstrap Tabs – Custom Post Type Query Loop in each Tab (Have to click twice to filter)
- How to Output which matched meta_keys were found from custom_type_posts?
- Bootstrap accordion looping through posts incorrectly
- Display custom post types in wp_list_pages
- Dynamic bootstrap tabs with post_title doesn’t display the_content
- Two custom post types divided in two columns inside a bootstrap carousel
- Different column width in 2 rows with bootstrap and custom post types-different classes needed
- Getting subpage of subpage – Custom posts
- Multiple categories assigned to a single product breaking the breadcrumb
- Make bootstrap 5.0 carousel dynamic using ACF and CPT UI [closed]
- Manually adding current_page_parent to wp_list_pages()
- build child and anchestor three from post parent
- Post list displaying wrong in Chrome and Firefox
- Wrap each child and it’s grandchildren separately
- Custom Post Type with Custom Taxonomy in Bootstrap 4 Accordion
- How to display data with pagaination on backend?
- Include Custom Post Type Archive in wp_list_pages
- Display a custom post type list by taxonomy term
- current_page_item and custom post type?
- Post content in bootstrap modal
- How do test if a post is a custom post type?
- Where to put my code: plugin or functions.php?
- What does this PHP function code mean? [closed]
- Remove slug from custom post type post URLs
- How to disable the single view for a custom post type?
- Custom post types, taxonomies, and permalinks
- Query all posts where a meta key does not exist
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- How to get all taxonomies of a post type?
- How to sort the admin area of a WordPress custom post type by a custom field
- How to create a custom search for custom post type?
- Deregister custom post types
- Can I assign a template to a custom post type?
- Permalinks: custom post type -> custom taxonomy -> post
- Should I use custom post types or a custom database tables for plugin development?
- Enable revisions for custom post type
- Extending the search context in the admin list post screen
- How do I query a custom post type with a custom taxonomy?
- Adding a Custom Post Type into the menu screen
- Pagination not working with custom loop
- How to Add Tags to Custom Post Type?
- How come Featured Image isn’t showing up in my Custom Post Type?
- Custom Post Type URL Rewriting?
- Add category base to url in custom post type/taxonomy
- Include custom taxonomy term in search
- Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu
- Adding ‘menu order’ column to custom post type admin screen
- Capabilities and Custom Post Types
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- what is the correct way to compare dates in a WP query_posts meta_query
- Use register_post_type() to modify an existing post type
- Custom Taxonomy specific to a Custom Post type
- Renaming Custom Post Types and Taxonomies
- List all posts in custom post type by taxonomy
- Redeclare/Change Slug of a Plugin’s Custom Post Type
- Allow member to have access to custom post type only. Permission to only edit their own posts
- Mixing custom post type and taxonomy rewrite structures?
- Advanced search form with filters for custom taxonomies and custom fields
- Highlighting wp_nav_menu() Ancestor Class w/o Children in Nav Structure?
- Resolve a custom post type name vs. page permalink conflict (same slug)
- Get custom post_type’s archive URL
- Enable Gutenberg on custom post type
- Is there a way to get N number of WYSIWYG editors in a custom post type?
- Can multiple custom post types share a custom taxonomy?
- How to Add Custom Fields to a Custom Post Type?
- Hook for post and page load
- How to enqueue scripts on custom post add/edit pages?
- How to display value of custom fields in page
- Where are wordpress custom types stored?
- Using save_post to replace the post’s title
- Custom Post Type pages are “not found”
- Possible to hide Custom Post Type UI/Menu from specific User Roles?
- How do I safely change the name of a custom post type?
- Custom post type single page returns 404 error
- Change “Enter Title Here” help text on a custom post type
- Hide content box with Custom Post Type?
- Change the text on the Publish button
- WP REST API fetch posts from post type
- Remove taxonomy slug from a custom hierarchical taxonomy permalink
- Adding categories to custom post type in permalink
- Load a script just to custom post type in admin
- Display all posts in a custom post type, grouped by a custom taxonomy
- How do you use a CPT as the default home page?
- get_terms by custom post type
- single-{$post_type}-{slug}.php for custom post types
- How do you use orderby with meta_query in WordPress 3.1?
- Custom post type single-{custom}.php not working
- How to get custom post type post id from slug?
- Programmatically publish a post (custom post type) with custom fields
- How to Add a Sub Menu Page to a Custom Post Type?
- Prevent post from being published if custom fields not filled
- WP_Query Pagination on single-custom.php