0

Currently I am using this-

add_rewrite_endpoint( 'download', EP_PERMALINK | EP_PAGES );

add_filter( 'query_vars', 'add_query_vars');
function add_query_vars($vars){
    $vars[] = "download";
    return $vars;
}

Then this to generate url-

global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
$book_download_url = $current_url."/download/{$value}";

Both the parts are working fine and give-

...post_url/download/42xcd

But I want to do the second part in wordpress way.

add_query_arg gives

...post_url?download=42xcd

from code-

$__new_url = add_query_arg('download','42xcd');

while I want to have

...post_url/download/42xcd

What am I missing here? Or any other approach? I tried set_query_var too.

2

0

Your Answer

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

Browse other questions tagged or ask your own question.