WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to set first post image to display in home page featured image (23 posts)

  1. funrockerz
    Member
    Posted 3 years ago #

    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..

  2. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    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

  3. funrockerz
    Member
    Posted 3 years ago #

    Hey EMil..Just Tell Me the place/file where should it be pasted

  4. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    index.php

  5. funrockerz
    Member
    Posted 3 years ago #

    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">

  6. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    go to http://pastebin.com and paste your index.php there, I will add this for you :) Just content from index.php

  7. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    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,
    Emil

  8. funrockerz
    Member
    Posted 3 years ago #

    http://pastebin.com/4FBtrYWt

    i did buddy ..i pasted the index file..please help me

  9. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    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.

    http://pastebin.com/nqpDQet1

    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.
    Emil

  10. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    Another 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); ?>
  11. funrockerz
    Member
    Posted 3 years ago #

    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 you

  12. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    No 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/

  13. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    Also your site is now redirecting to http://credit-news.org/?

  14. funrockerz
    Member
    Posted 3 years ago #

    Upgrade to wp latest has been done..now check my site and tell me

  15. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    nice! If you need anything else, please let me know :-)

  16. funrockerz
    Member
    Posted 3 years ago #

    i just want 1 image to appear in home page..

    cant we do that?..as it is showing 2 same pictures...of a post

  17. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    Yes, don't insert the image into post, plugin will grab the first image from your media of that posts. Just upload the image, but don't insert into actual post. This way you'll have only one, instead of two.

  18. funrockerz
    Member
    Posted 3 years ago #

    Ah, No I upload akon pic..i did not appear either..
    Neither it is showing text of no image found
    what shall i do now?

  19. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

  20. funrockerz
    Member
    Posted 3 years ago #

    but now they are coming twice my dear..

    as it was not showing anything i uploaded in actual post..
    are you in gmail?..can we chat

  21. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    sure

  22. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    I am glad to help, enjoy your site and thanks for making this resolved :-)

  23. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    @pakeeza1990 this topic is resolved :)

Topic Closed

This topic has been closed to new replies.

About this Topic