0

Here, i have a modal, where it holds my featured image. What i want is, how can i link my featured image to a file/pdf so that if user clicks the featured image, then there will be a pdf downloaded.

Problem: All i want is to link my featured image to a file. How can i do it? where the user uploads a file in the media and how can i link it with my featured image?

Here i set my modal to a post. Here is my code:

<!-- Modal -->
<div id="myModal38" class="modal fade" tabindex="-1">
<?php $idObj = get_category_by_slug('water-pumps-modal'); 
    $args1 = array(
        'post_type' => 'post',
        /*'category_name' => 'modal',*/
        'category__in' => array( $idObj->term_id ), // Take only IDs of the categories
        'posts_per_page' => '1',
    );
    $modalPost = new WP_Query( $args1 );
    if( $modalPost->have_posts() ) : 
?>
    <div class="modal-dialog">
    <?php while ( $modalPost->have_posts() ) : $modalPost->the_post(); ?>
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" type="button" data-dismiss="modal">×</button>
                    <h4 class="modal-title"><?php the_title(); ?></h4>
            </div>
            <div class="modal-body">
                <?php the_post_thumbnail(); ?>
                <?php the_content(); ?>
    <?php endwhile; ?>
            </div>
    <?php endif; ?>
    <?php wp_reset_postdata(); ?>       
            </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal -->
5
  • where do you store the url of pdf file ?
    – GKS
    Dec 9, 2016 at 4:37
  • @GovindKumar thank you for your answer sir i add/upload the media file only sir. and i dont know how to link it dynamicaly?
    – Jc John
    Dec 9, 2016 at 4:39
  • ok then you have to put that link inside post's meta data. learn more at designmodo.com/wordpress-post-meta
    – GKS
    Dec 9, 2016 at 4:41
  • @GovindKumar how sir ? can you post something tutorial ?
    – Jc John
    Dec 9, 2016 at 4:43
  • designmodo.com/wordpress-post-meta this tutorial is best for beginners.
    – GKS
    Dec 9, 2016 at 4:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.