0

Here's what I'm trying to achieve: I have a set of PDF files stored in a single directory on the server. Users should be able to enter the id of a file (filename without the extension) and click the Display button. The button should load another page with the file id as a part of the URL. The corresponding PDF file would then be displayed.

What is the simplest way to get this behavior? The PDF files are displayed using a shortcode. How can I dynamically generate the shortcode with the right file path? Any suggestions would be greatly appreciated.

Sasha

0

If you would show pdf in content dynamically, which page would you like to show page, post or wherever. You have to echo your shortcode in template file. For example, you have to print like below

<?php echo do_shortcode("[shortcode pdf='. $_REQUEST['pdf_id'] ."); ?>
http://yourwebsite.com/post-title/?pdf_id=20 //your url would be like that 
  • Thanks, por. I got this page to work with URL parameters. I'm setting it up with a sidebar to contain the text field and the button, with the PDF display in the main page. Any thoughts on how to better set up the text field/button combination with the correct action when the button is clicked? – Sasha Mar 26 '17 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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