Support » Fixing WordPress » Need help adding link to PDF in search and archive

  • In the template I am using, there is a link to pdf at the end of each entry on the single post page. It seems to be accomplished with the following code:

    `<div class=”entrytext”>

    <?php the_content(‘<p class=”serif”>Read the rest of this entry »</p>’); ?>

    <?php link_pages(‘<p>Pages: ‘, ‘</p>’, ‘number’); ?>’

    When I try to carry over the relevant piece from the above code, it only works if I bring over the entire entry as well as the link to PDF.

    See here:
    At the end of the entry I get the link to a PDF.

    But here in search results:

    And here in the category listing:

    I can’t get the link to PDF to appear under the entry title, like this:

    White Chocolate Pecan Truffles
    Download PDF: White Chocolate Pecan Truffles.pdf

    Chocolate Truffles
    Download PDF: Chocolate Truffles.pdf

    Another issue: there seems to be a limit on the # of items returned in a search or a category archive on a given page. I want to make that unlimited. Help?



Viewing 8 replies - 1 through 8 (of 8 total)
  • 1. There is nothing in your code at the top that links to a pdf file :0

    2 & 3. You have quite a customized archive.php and search.php – displaying only the titles. Who did that if not you?
    (archive.php is displaying your categories)

    Edit the file and add the_content

    4. The # of posts displayed is set by you: Options > Reading: Show at most…

    Thanks for solving the # of posts displayed problem.

    re: 1, i am sure that code delivers the PDF. If you view source on one of the single entry pages, you can see that the php rendered the link to the pdf.

    re 2&3 I have been tinkering with the default template. But I don’t understand your comment, “Edit the file and add the_content”

    please explain.



    <div class="entrytext">
    <?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
    <?php link_pages('<p>
    Pages: ', '</p>', 'number'); ?>'

    Produces this:
    <p>Download PDF: <a id="p276" href="">Bourbon Pumpkin Cheesecake.pdf</a>

    But only on the single post page. Why can’t I get this to work on the search or category page?

    I read through that and another page dedicated to categories. Maybe I am just dumb as a post…but I don’t see a solution in there.

    Can you elaborate?



    Different views in WP are shown by using different template files from your theme.

    You are showing/quoting above the code from your signle.php file which is used to display this:

    When you view a category archives, like this:
    the template file in action is archive.php.
    That one, obviously does NOT have the code youo are claiming it has.
    Hmmm… on a closer look: it has but it is commented out by certain individual named “Matt”. Talk to him.

    exactly! We aren’t communicating very well here. If I uncomment that bit it will show:

    1) the entire entry; and
    2) the link to the PDF

    I don’t want the category or search pages to show the entire entry, just a title (linking to full entry) and the link to the PDF.

    When I uncomment that bit of text you saw here:
    AND also remove the code that seems to render the full entry, I also lose the link to the PDF. Its as if the link to the PDF is dependant on showing the full entry as well.

    I don’t get it.

    Thanks for hanging in there helping me.



    update: I have moved the sit to a new URL:

    Also, I still don’t have any idea why this isn’t working. Please help!


Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Need help adding link to PDF in search and archive’ is closed to new replies.