how to set first post image to display in home page featured image
-
http://songlyricsz.com..
i do not know what it is called featured ,thumbnail or screen image…
check this site..
its showing everywhere no image found..how do i set first post image to those image gaps.suggest me some easy work to correct this..i am a newbie..
suggest copy paste coding or plugins or anything ,Big thanks..
-
Add this before the content:
<?php $images = get_children( array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999)); if ($images) : $total_images = count($images); $image = array_shift($images); $image_img_tag = wp_get_attachment_image($image->ID, 'thumbnail'); ?>
and you can add this in place where you want your first image to display:
<div class="thumbnail"> <a href="<?php the_permalink();?>"><?php echo $image_img_tag;?></a> </div>
Recommendation before anything would be for you to upgrade your WordPress you’re using outdated:
<meta name="generator" content="WordPress 2.8.5" />
Current version is 3.0.4 🙂
Emil
Hey EMil..Just Tell Me the place/file where should it be pasted
index.php
here is the Index file..
<?php get_header ();?>
<div class=”cWrap”>
<?php if (is_home()): ?>
<div class=”jad” id=”jad”>
<div class=”colL”>
<div class=”tabs”>
<ul class=”ulnav” id=”tabNav”>
<li id=”ra”>Recent Articles
<li id=”mp”>Most Popular
<li id=”mc” class=”last”>Most Commented//Shall i paste here the 1st code????????????????????????????????
<div class=”clear”></div>
<div class=”tabbody” id=”tabContent”>
<div id=”mc_content”>
<?php
$my_query = new WP_Query(“orderby=comment_count&order=desc&showposts=4”);
if ($my_query->have_posts()):
$tPi = 1;
while ($my_query->have_posts()) : $my_query->the_post();
?>
<div class=”fContent2″>go to http://pastebin.com and paste your index.php there, I will add this for you 🙂 Just content from index.php
You can also download http://wordpress.org/extend/plugins/simple-image-grabber/ and insert this code where you want your images to appear:
<?php images('1', '150', '200', 'alignleft', false); ?>
#1 = Number of images
150 x 200 = Size of the image
alignleft = Position of the image, in this case aligning left, you can use:alignleft, alignright, aligncenter.
Cheers,
Emili did buddy ..i pasted the index file..please help me
All right, my first post will not help, however the plugin will. I changed all images to work with the above plugin. Please backup your index.php before you upload this. However prior to that install and activate the plugin.
What I did was simple change, where I removed the image placeholders in your index.php and added this:
<?php images('1', '196', '147', false); ?>
All image sizes are according to what you had in your theme.
Now if everything else is all right, this should work just fine if not I am here to further assist you. Just make sure that plugin is installed and activated.
EmilAnother thing, as I pulled-up your site and see that images are coming up already, you have to be sure that each post does have the image in, otherwise nothing will be displayed.
For instance this http://songlyricsz.com/tik-tok-kesha-wake-up-3.html
You can also change the size of your images as well in:
<?php images('1', '196', '147', false); ?>
Hey Emil…Thanks a Lot..that worked..you have solved my major problem..
Thanks..you can see http://songlyricsz.com/ its showing all Images..
But small problem came.. if you scroll down little more then we see there are 2 same images coming,
and in post page
http://songlyricsz.com/enrique-iglesias-maybe-im-addicted-lyrics-31.html
still there is No image found .. When i have given the image..can you please solve this also??
its great to have youNo problem, when plugin is activated, you don’t need to instert images in posts at all as it will grab the very first image you posted under that post. That’s why you have two images.
Did you delete your WordPress? I don’t see anything anymore http://songlyricsz.com/
Also your site is now redirecting to http://credit-news.org/?
Upgrade to wp latest has been done..now check my site and tell me
nice! If you need anything else, please let me know 🙂
i just want 1 image to appear in home page..
cant we do that?..as it is showing 2 same pictures…of a post
- The topic ‘how to set first post image to display in home page featured image’ is closed to new replies.