-
Add the PDF attachment ID as a custom field value, for example
attached_pdf_id
. -
Get the URL using
wp_get_attachment_url()
:
<?php
if ( is_user_logged_in() ) {
$pdf_link = wp_get_attachment_url( get_post_meta( get_the_ID(), 'attached_pdf_id', true ) );
if ( $pdf_link ) {
?><a href = "https://wordpress.stackexchange.com/questions/89809/<?php echo $pdf_link ?>" >Download</a><?php
} else {
?>Sorry, no link available. Please contact the webmaser.<?php
}
}
?>
Related Posts:
- Permalink / sub-template issue
- How to use relative links on my pages?
- How can I store page ID in a post instead of other selected permalink?
- How to get a page url by a page id?
- Why does WP not use relative links when linking pages?
- Menu Link Redirect Based on Username or User ID
- Social Media Links on homepage – within posts/post loop
- Change website URL without breaking links or images? WP 3.3
- Is it possible to list post attachments in a sub URL endpoint with a dedicated template?
- Redirect user if it’s not logged in
- How to get full content including template HTML
- WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)
- I copied my site to another site but all links point to old site
- Link to blog index from template
- Change author slug and functionality
- Best way to add internal link in widget
- Confusion about how a URL is being parsed
- Automatically append ID to at the end of specific URLs
- why some permalinks adding characters/ruining links
- Avoid WordPress categorizing a permalink request as Not found 404 Page
- How to change old permalink?
- Migrated from Windows to Linux. Any bulk methods for fixing case sensitivity?
- How to eliminate permalink prefix in WordPress Multisite
- Get the url of a page template without using the page slug and ID
- All top-level pages are using index.php as template
- How to generate a list of all urls
- WordPress Not Using Template Files After Permalink Update
- Changing permalink name redirects to another template?
- Format HTTP links
- Edit permalink for certain pages
- cannot link a external url, present page url acting as parent url
- Can WP give a value a post ID?
- implement separate templates for 1 post type
- Moved site, Old links in pages still pointing to old host
- How to use page jumps to top of banner and page title?
- Access or edit custom generated permalinks with WP_Rewrite
- How to remove the link of an image on WP 4.2
- optional parameter in permalink structure
- Create custom links for excerpts with php dynamically
- How can I see a list of all pages my WordPress site has generated?
- How to make different urls for some tags pages
- A dash can replace a period in a link, how to fix it
- My WP homepage works, but the other pages don’t when accessing from out side of my network
- Can I link to content dynamically from a page to a new page?
- Propper way to set anchor and url param
- Find internal links to post
- rebuilding/ rewriting a url to make it SEO friendly
- Remove link function from oembed image or video
- Single.php not loading when permalink only contains date information
- Rewrite single template permalink?
- How to change dynamic link to relevant post
- Difference and usage of uri (e.g. get_directory_uri) and absolute path (e.g. get_directory)
- single.php being ignored, going straight to attachment.php
- Possible to hide parts of the slug from get_template_directory_uri and bloginfo(‘template_directory’)
- After changing permalink settings, everything works fine except for the two most recent posts
- Select page/template from the permalink url
- Latin character conversion
- Pretty links for PHP pages above WP /blog directory?
- Permalink structure as code in back-end?
- What is the issue with our links? It creates a loop
- Text in permalink
- Choose template depending on URL
- Image not Showing (Can see image in inspect element)
- PHP Button Custom link [closed]
- Make all internal links relative, or otherwise make a website accessible from multiple domains
- Change media item permalink
- What is the difference between get_permalink vs get_the_permalink?
- Is the permalink structure /%post_id%/%postname% faster or slower than just /%postname%?
- How can I force WordPress to redirect to canonical permalinks?
- Use Single Blog Post as Site Front Page Without Redirect
- wordpress permalinks tweeks
- Getting links to work the same on development and production
- Setting up two separate blogs while using WordPress as a CMS
- Custom theme navigation
- get permalink and append it
- How to redirect to correct pages after permalink structure change
- Only plain permalinks working
- Changes in permalink structure in WordPress and how to apply to in-site links
- WordPress disallows changing page to a specific permalink
- Permalink Doesnt Work – URL Not Found
- WordPress 4.4 old permalink redirect
- 404 when going to /blog
- Empty permalinks settings in .htaccess
- Rewriting single post url; add_rewrite_rule problem?
- curl problem or permalinks
- Multiple permalinks
- custom query var NOT working on a plain permalink: http://10.8.10.9/?page_id=1774/?location=968&floor=1
- How to flush Global query variables in wordpress?
- How to disable permalinks to some custom post content?
- How to add a base/front slug/url to specific post types?
- Permalinks by Post Name Are Not Working
- Change url of page according to my requirements in wordpress
- I use wordpress wp-page navi
- Multiple Taxonomy Items for Separate URLs
- Permalink issue with WordPress Site at domain root and another WordPress Site in a Subfolder
- Custom optional parameter in page URL
- Uppercase vs. Lowercase page slugs
- How do you intercept the page requests in WordPress?
- WooCommerce product permalinks
- Why doesn’t my page know it’s a page (won’t return true for is_page())?