php – ask about add_rewrite_endpoint query_vars
Question
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
please help me to fix my issue. thanks
0
2 months
2023-04-07T06:32:06-05:00
2023-04-07T06:32:06-05:00 0 Answers
0 views
0
Leave an answer