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
- Get the first post term
- Add Category Taxonomy Support to Custom Post Type
- Registering custom taxonomy with unique name, a good practise?
- When we register a custom taxonomy or post type, does the WP database modified at all?
- Custom post types and child theme
- Post Type only showing for “Admin” under “Appearance” > “Menus”
- Make the ‘all’ filter default instead of ‘mine’ in a custom post type
- How to Add Pages Under Custom Post Type URL Structure?
- Remove base slug in CPT & CT, use CT in permalink
- Query for posts from any post type but only add instock products
- WP insert post PHP function dynamically generated Custom Fields
- Change Post Title Edit Box
- How to keep a check box in custom meta box for custom post type checked by default for add new post?
- Disable feeds for specific custom post types
- Check Title Unique Or Not and If not error message and dont save
- 1 day after custom date change post status to draft
- Menu Multiple Taxonomies
- remove child post from custom post type archive
- Remove duplicated values from a loop
- Count all comments of a custom post type
- Conditional tags don’t work
- How can I create a custom meta box to add an mp4 video to a page?
- Pull a post based on a meta value in a custom post type
- Dynamic page outside WordPress
- Custom post type permalinks
- Exclude Post Type from Jetpack Infinite Scroll
- Search Custom Post Type & Taxonomies
- Help need making decision. Ads rotating site on wordpress
- Categories of custom taxonomy don’t show any posts
- Can a Custom Taxonomy be named “category” like normal Posts?
- Able to edit custom post, but unable to create new custom post when within submenu. What capability is missing?
- 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
- Add custom post type drafts to RSS feed
- Deleting taxonomy terms and relationships on a custom post_type when a user is deleted
- cutsom posts 404ing
- Save Multiple Metabox values
- Why does accessing url by category cause issues with post types?
- Sorting posts by custom field value in array
- Custom post types problem
- How to get postname in custom page?
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- How to populate a Gravity Forms Custom Post Field (dropdown type) with custom taxonomy terms? [closed]
- Render a Post or Page using the correct file
- WordPress Count posts within a custom post type
- Send email messages after comment was submitted
- Twitter Product Cards
- Custom Post Type Root Template
- comments hooks on custom post type
- custom post template ignored after altering permalinks
- Custom Post Type Implementation
- Visualize info in just custom post_type in theme
- Cannot get to work tax_query array for terms
- Using Orderby and meta_value to order natural/alphanumerical
- CPT UI: Connect a custom post type to a custom post type
- exclude admin archive edit screen
- Using post title in an array
- What’s the most efficient way to get two queries based on an if statement?
- Custom Post Type rewrite url to /category/pagetitle [duplicate]
- Custom post type URL – filter by taxonomy
- How do populate a column when listing custom posts?
- Archive page for a custom post type using WPML
- single-{post-type}.php
- Separating a custom taxonomy from blog post-type
- Custom post type and category permalinks
- Display read only info on admin, custom post page
- Bulk edit for custom taxonomy
- Good practical way to do loop within loop to show child custom type using a template code
- Pagination on category pages using wp_pagenavi causes 404 errors
- How to automatically compare date from custom post type with current date and change taxonomy based on a result?
- select categories by ids/display terms only selected
- How to exclude a certain CPT from a snippet for Dashboard box?