There are different filters available to create the custom permalinks for the posts, custom posts or pages:
- post_type_link – for custom post types
- post_link – only for post_types ‘post’
- page_link – for pages only ( which you are looking for )
Here is the sample code based on your query:
public function custom_permalink_for_page_template( $url, $post ) {
if ( is_page() && is_admin() && is_page_template( 'custom_page_template' ) {
return str_replace( get_site_url(), untrailingslashit( get_site_url() ) . "/custom-permalink-structure", $url );
} else {
return $url;
}
}
You can also validate the permalink structure settings in the if condition
get_option( 'permalink_structure' )
Related Posts:
- Customize permalink wordpress category id
- How to remove custom post type and add category and post name
- post id or permalink auto-incrementing number and reset everyday
- How to call a plugin function from index.php
- Rewriting every url
- Plugin update error message
- How to handel multiple checkbox field in the admin settings page with Settings API
- wp_insert_user – how to send verification email before logging in
- Is the WordPress HTTPS Plugin Still Safe To Use? [closed]
- Set a User as Author of all ‘New Posts’ posted
- Post source link plugin – small modification
- Passing URL parameters to WordPress pages and pretty url
- How do you auto-activate plugins from child themes
- How to prefix `attachment` permalinks with `attachment`?
- How to get the custom page get_permalink?
- How to set “with_front’=>false” to a plugin-generated cpt?
- How to load plugin before the wordpress jquery?
- What is the function to get plugin base url in multisite?
- Code in theme functions.php faster than with a plugin?
- Add a Custom Permalink option in the Permalink Admin Screen?
- Override the core function locate_template
- Trying to count the total number of paragraphs inside a blog article
- How to get post URL in the_content filter?
- May i Use ShortCode in Template?
- Pass info from functions.php to plugin
- add_query_arg not working
- How do I add a custom sub menu menu under Woo-commerce marketing?
- Changed permalink structure. Need help with redirecting old posts
- Change permalink structure hidden button edit
- Inserting HTML tag with ACF into shortcode
- How to Display a Plugin function (content) on frontpage using index.php
- Theme my Login plugin, how to update fields
- AddToAny shortcode in the loop
- ‘No Results Found’ on single post for custom post type
- get current date + 90 days and checking every day
- How to create an input field, and base the output on spreadsheet data? [closed]
- Admin style for just one plugin in dashboard
- Using arbitrary paths in page urls
- plugin links not working [closed]
- How to set Noindex to all wordpress pages in a catergory?
- Load Javascript from Plugin in One Page Only?
- URLs Added to ACF Repeater Field are not working
- How to keep variable `$post` to using in another file
- Plugin Development – Functions or Hooks?
- wp_dequeue_script for a Plugin
- wc_get_template new template does not showing up
- Overriding an Array in a Plugin’s Class/Function from functions.php
- How to remove a class function from a plugin by using remove_action()?
- How to translate wordpress error message
- Api external with wordpress
- Hook for altering the content of all wp mails
- I want to filter my products with attributes [closed]
- How to get rid of Ellipsis on Woocommerce [Essential] Theme [closed]
- Sharing functions between plugins
- More gentle way to hook WordPress custom url
- Pull comments from one page/post into another page/post?
- Permalinks and pagination are not working in WordPress with WP e-Commerce plugin
- How to makes changes on the shop/category/tag pages but not on the product pages in woocommerce?
- Oops! That page can’t be found
- implement custom roles in custom plugin
- How to get current cart values using WC_Shortcodes?
- How to copy the all WordPress media items to another custom plugin folder?
- FPDF for creating pdf diplomas
- WordPress default post categories meta box widget
- Fatal error “Call to undefined function is_plugin_active” each time the plugin is activated
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Child theme modifications not showing up
- Make modification of add_to_cart button specific to single page
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- how can export data in excel file custom plugin
- added code to permalink (URL)
- WP_CRON issue with UTC and local time
- How to wrap image tag into div for post only?
- Update User Meta Via Ajax
- How to use custom footer template in a site-plugin?
- Unexpected plugin_dir_path Output
- Can plugin automatically update if i hide the update notification?
- how to repeat taxonomy in different places on wordpress
- how to create table during plugin installation in side a class
- Posting code inside the post instead of in the template file using shortcode
- How to use scripts when header/footer are stripped out
- Metabox Data not saving
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Change post permalink to external URL from custom field
- Can’t get custom user meta to show in header
- Including a PHP file via a function that is part of a plugin?
- overwrite a plugin function in functions.php
- Pass strings to plugin function [closed]
- How to tweak a plugin without preventing it from updating
- WP Members additional fields on user profile [closed]
- How to create a page template using custom plugin
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Display Video as Post Thumbnail
- Notifications Bar on home page only
- Does anyone have the Custom Post Permalinks plugin from John P. Bloch? [closed]
- Make plugin admin page visible to other roles
- wp_enqueue_script doesn’t load JS in plugin
- Getting 400 Error in wordpress website
- How to provide page_template path in custom plugin using WordPress