0

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.