-
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
- How to prevent apostrophes and quotes from appearing in permalinks?
- How to i18n slugs for templates?
- Add %taxonomy% in custom permalink structure
- Using WP rather than .htaccess to redirect pages/posts
- How can you receive the most recent permalink or terms of the newly saved post?
- echo post-permalink without http and www
- CPT Post Title Permalink: Replace “@” (or all special characters) with dash “-” instead of just removing
- Custom permalink for search and pagination
- Rewrite Rule for default post type
- WordPress permalinks that end with a hyphen result in a 404
- Programmatically Restrict WordPress from using certain URLs or sub-directories
- How to include sub directory in sitemap? [closed]
- How to handle broken links created by permalink/slug changes?
- add_query_vars and canonical links
- Changing the permlink and SEO
- whats the mistake → href=”get_permalink() [closed]
- How can I link to the author’s page
- WordPress pages and posts are redirecting to server IP address instead of domain URL [closed]
- new page redirect to old page which had the same permalink
- Long permalinks get split with multidots and get broken
- Homepage template and url changed?
- Automatisation permalinks for each making of new page
- How to create an IIS7 re-write rule for a single category
- How to link to specific part of a page in wordpress permalinks
- Find which Permalink structure is the best
- How can i edit all posts slug in bulk keeping WP native redirect?
- Post/page without slug
- Permalinks get lost periodically
- how to add permalink/slug to wordpress custom link menu item
- Stymied by 500.5 error for WordPress on IIS 8 / Windows Server 2012
- My posts images and links are not correct when I publish my home page
- How to remove parent slugs from child pages permalinks?
- How to add .html extension only to pages without child pages?
- changed permalink structure and now ajax functions are broken
- Changing the URL slug causes redirecting to homepage, or showing 404 or missing lang_code issue