Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #4497

    Is it possible in the Portfolio setup to make the read more button open a pdf file on my server or wp meda file?

    #46550

    Hey,

    yes – in template_portfolio.php replace:

    <a href="<?php echo get_permalink(); ?>" class="more-link">Read more</a>

    with:

    <?php if (get_post_meta($post->ID, 'pdffile', true) != ''){
    echo '<a class="more-link" href="'.get_post_meta($post->ID, 'pdffile', true).'">Download PDF document</a>';
    }else{ ?>
    <a href="<?php echo get_permalink(); ?>" class="more-link">Read more</a>
    <?php } ?>

    Afterwards add a custom field to all poprtfolio items with pdf documents. Call the custom field “pdffile” and as value type in the url to the pdf document.

    #46551

    Dude, (Since that’s your name) Love it,

    Thank you so much for your responses to all my forum questions.

    Regarding this one, is there a way to put a target_blank for these links so that they open in a new page or tab?

    #46552

    Yes that’s possible. Instead of the code I posted above use:

    <?php if (get_post_meta($post->ID, 'pdffile', true) != ''){
    echo '<a class="more-link" target="_blank" href="'.get_post_meta($post->ID, 'pdffile', true).'">Download PDF document</a>';
    }else{ ?>
    <a href="<?php echo get_permalink(); ?>" class="more-link">Read more</a>
    <?php } ?>

    #46553

    Hi there,

    Is it possible to do this for the ‘Avisio’ theme?

    Thanks.

    #46554

    Hey,

    yes – in template_portfolio.php replace:

    echo "<a href='".get_permalink()."' class='more-link'>".__('Read more','avisio')."</a>";

    with:

    <?php if (get_post_meta($post->ID, 'pdffile', true) != ''){
    echo "<a href='".get_post_meta($post->ID, 'pdffile', true)."' class='more-link'>".__('Download PDF document','avisio')."</a>";
    }else{ ?>
    echo "<a href='".get_permalink()."' class='more-link'>".__('Read more','avisio')."</a>";
    <?php } ?>

    Afterwards add a custom field to all poprtfolio items with pdf documents. Call the custom field “pdffile” and as value type in the url to the pdf document.

    #46555

    Hi there,

    Doing that breaks the page (just blank white)?

    #46556

    I’ve just found the post in the ‘Avisio’ section. All sorted now. Many thanks.

    #46557

    Glad that you solved the problem :)

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Read More Post to PDF’ is closed to new replies.