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
0
I think this may be of some assistance, hopefully. Good Luck!
-
-
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