0
votes

This is my link.php script for show latest title and tumbnail from my wordpress site. Title working fine thumbnail not work. it only show mysite/wp-includes/images/media/default.png, But my content have uloaded image. How can i get thumbnail image

 <?php
 require('../../wp-blog-header.php');
 ?>

 <?php
  $posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
 foreach ($posts as $post) : setup_postdata( $post ); ?>
     <?php get_the_ID(); echo "<br />"; ?>
   <?php the_title(); ?>    <?php echo "<br />"; ?>

<?php
   $imgId = get_post_thumbnail_id($post->ID);
   $imgUrl = wp_get_attachment_image_src($imgId,'thumbnail', true);
 ?>
   <a href="<?php the_permalink(); ?>"><img src="<?php echo  $imgUrl[0];  ?>" /></a>
 <?php
 endforeach;
 ?>
1

1 Answers

0
votes

In wordpress use the inbuilt function for including files so:

<?php get_header(); ?> - Providing header.php exists it will bring it in.

    <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 2600,1000 ), false, '' );?>
    <div class="front-page-post-img" style="background: url(<?php echo $src[0]; ?> ); background-size: cover; background-repeat:no-repeat;"></div> 


            <?php if(is_single()): ?>
            <?php the_content(); ?>
            <?php comments_template(); ?>
            <?php else: ?>

            <?php echo substr(get_the_excerpt(), 0,45); ?>
            <a class="post-link" href="<?php the_permalink(); ?>">more...</a>
            <?php endif; ?>