Ready to get started?Download WordPress


Display post url under post featured image (6 posts)

  1. hrrubin
    Posted 9 months ago #

    I'm trying to display a given post title under each post image (they are positioned in a grid). So far I'm only getting the current page url.

    	  $thumbnails = get_posts('numberposts=15');
    	  foreach ($thumbnails as $thumbnail) {
    		if ( has_post_thumbnail($thumbnail->ID))
    		echo '<div class="case">';
    		echo '<li><a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
    		echo get_the_post_thumbnail($thumbnail->ID, 'large');
    		echo '</a></li>';	
    		echo '<a href="' . get_post_permalink( $ID ) . '">' ;
    		echo get_the_title($ID); '</a>';
    		echo '</div>';
  2. keesiemeijer
    Posted 9 months ago #

    Try it with:

    echo '<a href="' . get_post_permalink( $thumbnail->ID ) . '">' ;
    echo get_the_title( $thumbnail->ID ); '</a>';
    echo '</div>';


  3. hrrubin
    Posted 9 months ago #

    Thank you. Any idea how to get the same permalink structure as the thumbnail link?

  4. keesiemeijer
    Posted 9 months ago #

    Can you explain some more what it is you want? Maybe changing get_post_permalink( $thumbnail->ID ) to get_permalink( $thumbnail->ID ).

  5. hrrubin
    Posted 9 months ago #

    I'm beginning to understand this structure. It worked of course.

    I have an idea about placing a short text underneath the title of the post, but that text should not be displayed inside the post.

    So for each post preview, there is a small text accompanying. Any idea how I should go about this?

  6. Pioneer Valley Web Design
    Posted 7 months ago #

    And then the OP gets a known hacks 'influence'...documented and noted.


You must log in to post.

About this Topic