0

I am trying to make download page with download link defined in posts custom field.
I want download pages to look like

/download?p=id

I found many sites using this kind of download links. Is there actually a simple solution for this? A plugin for instance? From my understanding i would have to make page template where i set up page as i want and as for the part i want to change based on post id i pull it out of custom field. Then making shortcode to insert download page link in posts.

EDIT
Based on Rarst answer i managed to make some progress.

1.Allowing endpoints such as ?id=

add_rewrite_endpoint( 'id', EP_PERMALINK | EP_PAGES );

2.Pulling out custom field from post based on permalink id.

<?php echo get_post_meta($_GET['id'], 'link', true); ?>

Now i have to figure out how to make posts shortlinks not easy to guess one by one and make shortcode. Any idea?

1 Answer 1

1

The most easy way to append something to the end of URLs and process it in WP are rewrite endpoints.

It makes it easy to target specific kind of URLs and generally it is unlikely to explode everything, like many of rewrite modifications do.

2
  • Thanks that put me on right track. Do you perhaps know how to make shortlinks (post id) a bit more complicated, so it cannot be guessed?
    – Recofa
    Commented Oct 2, 2017 at 23:42
  • I know there are libraries that allow you to generate reversible non-guessable identifiers from numeric IDs, but I don't remember any specific ones on top of my head.
    – Rarst
    Commented Oct 3, 2017 at 6:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.