Viewing 5 replies - 1 through 5 (of 5 total)
  • I did something like this, i used this code. You need to get the ID of the catigory and replace it in the code, and you also need to make a custom field named post-img then fill out the image path.

    <?php if(have_posts()) : ?>
     <?php $recentBlog = new WP_Query('cat=4&showposts=1'); ?>
     <?php while($recentBlog->have_posts()) : $recentBlog->the_post();?>
     <div>
      <?php $postimageurl = get_post_meta($post->ID, 'post-img', true); if ($postimageurl) { ?>
      <a href="<?php the_permalink(); ?>"><img src="<?php bloginfo('template_directory'); ?><?php echo $postimageurl; ?>" alt="<?php the_title(); ?>" /></a>
      <?php } ?>
     </div>
    
     <?php endwhile; ?>
    
     <?php else: ?>
    <?php endif; ?>

    Thread Starter Zuuring89

    (@zuuring89)

    thanks for the quick reply, now does this code make it so there is alsways a permanent image above all blog posts? Do you have any idea how to code in a featured article code?

    Yes, i just explained it, that code wil display one post from category 4. You just need to make a category named featured, then replace the ID in the code. After that you make a post with a custom field of post-img, and type in the url of the im, so like wp-content/themes/yourtheme/images/yourpic.jpg then it will display your one featured post.

    Thread Starter Zuuring89

    (@zuuring89)

    Awesome, I got the featured post article working as a sticky for the first part. Instead of having the other image as a catagory, is there anyway I can simply insert a static image above the post content much like a banner? If so would you happen to know the code? Does it just go in the index.php and page.php?

    thanks for all your help

    This problem is a nightmare for me and i tried everything, even what was mentioned above. Although I dont really understand it too well, i hope you can explain in more detail, my site looks rediculous with the only geatured image not showing up!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Featured Article/ Image above Blog’ is closed to new replies.