Home Forums Front-end Issues Link straight to pdf rather than the attachment page


Link straight to pdf rather than the attachment page

  • The Page Link Field Type is very useful and has made life a lot easier for me in many ways. I am using it in a template to allow a user to link to a pdf. It works fine as always except I want it to link direct to the pdf not to the attachment page. I have looked through the documentation and the forums and could not find any relevant info. The code that I am using in my template is:

    <p class="tx-c padt20"><a href="<?php the_field('pdf_link'); ?>" target="blank">Product PDF</a></p>

    Am I able to link directly to a pdf and, if so, can someone point me in the right direction? Thanks so much for your time.

  • Hi @johnhillcoat

    The page link field is exactly that – a link to the page.

    To link to the attachment file, you will need to change the field_type to post_object. This will then allow you to receive a post object / ID which you can use to load the attachment URL.

    Also, I believe the user experience will be much nicer if you use the file field to select a pdf file.


  • Thanks Elliot – good advice.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Link straight to pdf rather than the attachment page’ is closed to new replies.