how to change links from sample-domain. com/title-post/download to sample-domain. com/download/title-post
im use this code
add_rewrite_endpoint( 'download', EP_PERMALINK | EP_PAGES );
function download_links() {
add_rewrite_endpoint( 'download', EP_PERMALINK | EP_PAGES );
}
add_action( 'init', 'download_links' );
function download_templates() {
global $wp_query;
// if this is not a request for play or a singular object then bail
if ( ! isset( $wp_query->query_vars['download'] ) || ! is_singular() )
return;
// include custom template
include get_template_directory().'/template/download.php';
exit;
}
add_action( 'template_redirect', 'download_templates' );
if use this link < ? php the_permalink() ? >download/ working fine
but i want changes sample-domain. com/title-post/download to sample-domain. com/download/title-post
im using wordpress
please help me to fix my issue. thanks
#wordpress