• Resolved alanjacobs

    (@alanjacobs)


    Hi,
    I am trying to construct a do_shortcode so that I can display a PDF … but whatever I try I seem to get errors from, I think, pdf embedder saying that the PDF is missing.
    I have seen the other topic “Missing PDF” but that didn’t help.

    I am adding a Shortcode field to a single post template in Elementor.
    the code is very simple.

    
    $mediaurl = 'https://mysite/wp-content/uploads/2021/05/Sample.pdf';
    echo do_shortcode( ' [ pdf-embedder url=$mediaurl ] ' );
    

    But the error reports

    
    missing PDF "https://mysite/documents/670/$mediaurl"
    

    I have tried numerous different combinations of quotes and doublequoates but no improvement.

    So How do I actually call pdf-embedder in the shortcode?
    Why is the error reporting a missing PDF based off the url of the template itself rather than the actual media url?

    Thanks

    • This topic was modified 3 years, 10 months ago by alanjacobs.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @alanjacobs,

    The problem is that you have a PHP variable set into the shortcode; however, it isn’t being treated as a variable but as the text value. Try:

    
    $mediaurl = 'https://mysite/wp-content/uploads/2021/05/Sample.pdf';
    echo do_shortcode('[pdf-embedder url="'.$mediaurl.'"]');
    
    • This reply was modified 3 years, 10 months ago by PDFG Support. Reason: typo
    Thread Starter alanjacobs

    (@alanjacobs)

    Hi, Thanks. I tried that and the error has now changed. Now it is

    Unexpected server response (403) while retrieving PDF “https://mysite/docs2/670/’.$mediaurl.'”.

    It is still reporting the error against the url for the template rather than the media url. Not sure why it does that.

    Hi @alanjacobs,

    Can you please send us an email to [email protected] with the full code example. It would be easier to correspond through that channel. Could you also include what version of the PDF Embedder you are using (free, Premium, Secure, and version #).

    Thank you!

    Thread Starter alanjacobs

    (@alanjacobs)

    Sent
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to construct a do_shortcode that works?’ is closed to new replies.