• Resolved treefiddy

    (@treefiddy)


    At work we have been using a method of uploading a pdf file as a rate sheet, as seen here http://www.westernbanc.com/rates

    Recently the method we were using stopped working, after a plugin/wp update I believe.

    So what we were doing; I had created a new field in WP called Rate Sheets. In the field, someone could upload a PDF to the site and the code written would find the most current version of the PDF and embed it on the rate link I provided.

    Recently it has stopped finding the most current PDF and we have had to manually insert the PDF name / location where $link is located in the code. Here is the current code.

    functions.php

    // Send most recent rate sheet doc if found.
        function get_rate_sheet() {
    
            $item = get_posts(array(
                'post_type' => 'rate-sheet',
                'posts_per_page' => 1,
                'orderby' => 'date',
                'order' => 'DESC'
            ));
            if ($item) {
                $item = $item[0];
                $id = get_post_meta($item->ID, 'file', 1);
                $link = wp_get_attachment_url($id);
                /*
                if ($link) {
                    //header("Location: $link");
                    wp_redirect($link,301);
                    die();
                }
                */
                return $link;
            }
    
        }

    And the wbc_ratesheet.php code

    <?php
    /*
    Template Name: Rate Sheet
    */
    
    // Load the rate sheet doc.  Show page as fallback.
    $rateLink = $tcms->get_rate_sheet();
    
    get_header();
    
    global $post;
    if (have_posts()) {
    	the_post();
    }
    
    ?>
    <?php /*<h2 class="contentHeader"><?php the_title(); ?></h2>*/ ?>
    
    <!-- .contentArea -->
    <div class="contentArea">
    
      <h2 class="pageHeading"><?php the_title(); ?></h2>
      <div class="post">
        <div class="entry">
        	<div id="dlink"><a href="<?php echo $link; ?>" target="new">Download this rate sheet</a></div>
          <iframe src="<?php echo $link; ?>" frameborder="0" id="iframe2" style="width:100%;height:1030px" ></iframe>
        </div>
      </div>
    
      <div class="clear"></div>
    </div>
    <!-- / .contentArea -->
    
    <?php get_footer(); ?>

    Any clue as to why this is not working anymore?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Problem with PDF upload link’ is closed to new replies.