最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - Post Title to link to a PDF

programmeradmin3浏览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.

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.

Share Improve this question asked Dec 8, 2016 at 20:05 MWAMWA 33 bronze badges 2
  • I think this may be of some assistance, hopefully. Good Luck! stackoverflow/questions/19949381/… – mr__culpepper Commented Dec 8, 2016 at 20:23
  • The Page Links To plugin should take care of that without excess bloat. – Knut Sparhell Commented Oct 7, 2019 at 8:50
Add a comment  | 

1 Answer 1

Reset to default 1

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['...
    }
?>
发布评论

评论列表(0)

  1. 暂无评论