Link div group to selected Permalink?

I am creating a news centre which pulls in the newest wordpress post, of a specified category. It includes the post image and title. The div group has a hover animation, and i want that class, when clicked, to link to the post its pulling the title and image from.

Currently it only links if you click on the title itself, i want to be able to click the entire block and it link to the post. Any ideas? here is the code as it stands…

 <?php query_posts('cat=1 &posts_per_page=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="block-1">
        <div class="news-center-overlay transition">
        <p>VIEW FULL STORY</p>
            <div id="news-line-box">
            <div id="part-1"></div><div id="part-2"><img src="<?php echo get_stylesheet_directory_uri()?>/img/star.png"/> </div><div id="part-3"></div>
            </div>
            <h4>COMETS BASKETBALL</h4>
        </div>

        <a href="<?php the_permalink() ?>"><?php echo get_the_post_thumbnail( $post_id, $size, $attr ); ?></a>

        <p class="news-center-title animation"><a href="<?php the_permalink() ?>"><?php echo get_the_title( $ID ); ?></a></p>
    </div>
<?php endwhile; endif; ?>

Related posts

Leave a Reply

1 comment

  1. From my understanding, You are looking to click a Block with the link to the post that resides under the Block

    If this is the case, The Block can be wrapped in a href link or the href link can be wrapped to the news-center-overlay class

        <?php query_posts('cat=1 &posts_per_page=1'); ?>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
         <a href="<?php the_permalink(); ?>">
            <div class="block-1">
                <div class="news-center-overlay transition">
                <p>VIEW FULL STORY</p>
                    <div id="news-line-box">
                    <div id="part-1"></div><div id="part-2"><img src="<?php echo get_stylesheet_directory_uri()?>/img/star.png"/> </div><div id="part-3"></div>
                    </div>
                    <h4>COMETS BASKETBALL</h4>
                </div>
    
                <?php echo get_the_post_thumbnail( $post_id, $size, $attr ); ?>
    
                <p class="news-center-title animation"><a href="<?php the_permalink() ?>"><?php echo get_the_title( $ID ); ?></a></p>
            </div>
         </a>
        <?php endwhile; endif; ?>