• Could someone please tell me how I can display the latest pdf in page.php, after my client has uploaded it to the WordPress media library? With the pdf I need to be able to get the url and title. I know that my client’s web hosting account has the usage of pdfs enabled. Thanks in advance.

Viewing 8 replies - 1 through 8 (of 8 total)
  • When you upload a PDF using the Media Library/Gallery functions, only a link will be displayed in the page or post (they are not images)…as PDF’s can be opened natively in all modern browsers, the link is all that is needed. Adobe recommends certain ways to form the url for example to display at page 7.

    Thread Starter bluegum

    (@bluegum)

    Thanks for that, but my client wants those pdf links to be displayed on his website, and he wants to be able to change the links as he changes the pdfs, therefore I need someone to post some code to be displayed here. So just changing the pdfs by uploading them into WordPress will not do what my client requires.

    Why not? When you upload a new PDF, you get a new link. You can then delete the old one.

    Or you could do that once, then replace the PDF file through FTP, making sure that the name remains the same.

    One need only edit the page or post with the latest pdf, the old file with different name will still be in the library as long as it is not overwritten…it will also be in previous revisions.

    Thread Starter bluegum

    (@bluegum)

    Thanks fonglh, but how do I display the latest particular uploaded pdfs (not all of the pdfs which have been uploaded to WordPress) into page.php? It sounds too complicated for my client to replace the pdf file via FTP, who isn’t computer saavy.

    Sorry if I sound frustrated and stressed, but I have a deadline to meet here, therefore I need this completed asap, and my client is putting the pressure on me to get this finished.

    Here is the code which I have started:

    global $wpdb;
    $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1");
    $attachmenturl = get_attachment_link($attachment_id);;
    $attachmenttitle = ;
    
    echo '<li><a href="'.$attachmenturl.'" title="'.$attachmenttitle.'"></a>'.$attachmenttitle.'</li>';

    The whole idea is that you don’t have to edit page.php.

    When you add a PDF file using the standard WordPress backend, it inserts a link into the page. Just teach your client how to do that, and delete the existing link using the visual editor.

    You can insert more PDFs into 1 page if you want, and simply remove the links to the old ones.

    Thread Starter bluegum

    (@bluegum)

    Ok thanks, my client has a one page website, so now I don’t understand how no php code will display the pdfs. With the one page website, there will be blocks text which belongs to each button. So surely there has to be some way, I have to tell WordPress to display the pdfs in the website.

    To display the blocks of text I have created this code:

    $about_page_post_id = 10;
    $about_page_post = get_post( $about_page_post_id, ARRAY_A );
    $content_about = $about_page_post['post_content'];
    echo $content_about;

    Take a look at how the default theme (twentyeleven) displays pages.

    The page content, which can be viewed in the visual editor of the admin interface, will contain the links.

    Thus your theme just has to display the page content.

    http://codex.wordpress.org/The_Loop

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Please tell me how I can display the latest pdf’ is closed to new replies.