0

I want to link a Post Title to the PDF. I feel my solution is somewhere in wp_get_attachment_url() but I can't figure out how. Also, I'd like my pdf to be located in ../wp-content/uploads/year/month/pdf-name.pdf for about 12 post going back 2 years. Please point me in the right direction. Thanks.

0

I think this may be of some assistance, hopefully. Good Luck!

https://stackoverflow.com/questions/19949381/how-can-i-link-wordpress-posts-title-to-pdf-file-download

  • I stared at that one a couple of times... Can't figure it out. – MWA Dec 8 '16 at 20:46
  • Try going into the index.php and changing <?php the_permalink(); ?> next to – mr__culpepper Dec 9 '16 at 16:05
  • Try going then go into the index.php and changing <?php the_permalink(); ?> next to <?php the_title(); ?> to <?php echo get_post_meta($post->ID, 'pdf-link', true); ?> – mr__culpepper Dec 9 '16 at 16:09
  • Try going and creating a custom field on the post and use the pdf link as the field Then go into the index.php and changing <?php the_permalink(); ?> next to <?php the_title(); ?> to <?php echo get_post_meta($post->ID, 'pdf-link', true); ?> Hope that helps, sorry about all he weird comments :-Z – mr__culpepper Dec 9 '16 at 16:10
  • Apologies, if you;d like this done on the single page post instead of the post index you should do the same except on the single.php file. Change <h1 class="entry-title"><a href="<?php echo get_post_meta($post->ID, 'pdf-link', true); ?>"><?php the_title(); ?></a></h1> – mr__culpepper Dec 9 '16 at 16:30
0

I recommend using the plugin Advanced Custom Fields (Very popular plugin). It lets you create fields and manage their values very easily.

This way you could just create a new field for file upload and then to pull its information like this-

<?php
    $my_file = get_field('my_file');
    if( $my_file ) {
        echo $my_file['url'];
        echo $my_file['alt'];
        echo $my_file['...
    }
?>
  • I'm trying to stay away from using a plugin to do this. I feel like it should be a pretty simple operation. Just can't believe I'm the first dev to try and do this. – MWA Dec 8 '16 at 20:48
0

The Page Links To plugin should take care of that without excess bloat.

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.