The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Help on Image for each post title (51 posts)

  1. rajesh0228
    Posted 6 years ago #

    t31os, if you're reading this post let me remind you about a old thread - http://wordpress.org/support/topic/250685 -
    related to inserting an image alongside the post/page title.

    I am using the default theme in my site. I tried implementing your technique(which uses a custom-field) but it didn't work.

  2. rajesh0228
    Posted 6 years ago #

    t31os, in which PHP file you want your codings to be inserted? Is it Index.php? Should the custom field value contain the name of the image file - with extension? I ask this coz you'd hard-coded an extension(.jpg) in your example. Btw, what does "Adjust the CSS" mean?

  3. rajesh0228
    Posted 6 years ago #

    t31os, I need your help. Or for that matter, anyone can help on t31os behalf.

  4. Mark / t31os

    Posted 6 years ago #

    I'll have a look at the thread, etc.

    Give me a few minutes and i'll see what i can do to help.. ;)

  5. Mark / t31os

    Posted 6 years ago #

    Looking back at that thread, it was 1 year ago, and i don't use WPMU(i installed at that time to test), i believe you're referring to the WPMU code toward the end of the thread, correct?

    It's also quite old code, i've learnt alot since then, so i'd probably suggest something different now.

    Are you using WPMU and what is it you're trying to do exactly, same as the user in the other thread?

    Apologies for the delayed response, hadn't noticed your thread before your last reply.

    Sorry i really should read things twice, you did mention it in your opening post, bear with me and i'll look at the thread again.... :)

    EDIT 2:
    Are you referring to this piece of code?

  6. rajesh0228
    Posted 6 years ago #

    t31os, WHAT A RELIEF! At last you'd detected my SOS 2 you!

    Yes, I am referring to the code link you'd given.
    And no I am not using WPMU at all.

    What I am trying to do is to insert an image to the left of the page/post title. How to do it - sans using any plugin? Therefore, I'd asked those questions in my 2nd posting above.

  7. Mark / t31os

    Posted 6 years ago #

    As indicated in the original post, it would go inside the <head> area, which is only ever in one place of your theme, the header.php file.

    However i'm not sure how that code really applies to what you seem to be asking to do..

    So rather then refer back to old code, shall we maybe focus on what you want to do and i'll make a fresh suggestion on how to do it based on what i know now(alot more then a year ago).

    Let me see if i have this right, are you referring to placing images next to post titles on your index page? (or a particular area/page) .. on which, you wish to pull an image to be used, based on that particular post's custom field (or page, same applies). Is that correct?

  8. rajesh0228
    Posted 6 years ago #

    t31os, what I want is simple & straightforward.I want an image (thumbnail type) to the left of each & every post/page title (separate image for each post/page title).

    Btw, if I recall correctly I'd inserted your username - t31os - at the beginning of the title of this thread. But, strangely, it doesn't exist! Why? Do you've any answer?

  9. Rev. Voodoo
    Posted 6 years ago #

    @t31os probably doesn't want their user name in the title and edited it. There's no need to put usernames in titles of threads.... it won't get any special attention. You're best to just ask your question and see who answers. Many people have much to offer here.

    In regards to your question....you want a thumbnail beside your title on each post. Times have changed, WP has changed. Its easier to do now.

    First, learn how to use thumbnails in general.

    is a great writeup on how to use thumbnails.

    I implement it on my site here, and I think I do exactly what you are asking.

    read the tutorial and set up your theme.

    my functions.php looks like:

    if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 50, 50, true ); // Normal post thumbnails
    	add_image_size( 'single-post-thumbnail', 300, 999 ); // Permalink thumbnail size
             add_image_size( 'title-image', 50, 27 ); // Title mini photo

    this all sets up the thumbnails, and gets various sizes. The tutorial will help you understand that.

    This portion here:

    add_image_size( 'title-image', 50, 27 ); // Title mini photo

    specifically sets up a little icon sized image for beside my titles

    then in my index.php, before the line that calls my title, which looks like:
    <div class="titleText"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></div>

    I've inserted:
    <?php the_post_thumbnail('title-image', array('class' => 'titleImage', 'alt' => 'Title Icon')); ?>
    which drops in the icon sized image (title-image) I set up previously in functions.php. It also gives it a class of titleImage for my css

    and in my css I have

    .titleImage {
            margin: 9px 10px 0 5px;
            float: left;

    which gives it a margin of space, and floats it to the left of my title

    This probably can't be directly copied into your theme without modification, but this is how it's done. With my stuff here and that tutorial, you should be able to get something going

  10. Mark / t31os

    Posted 6 years ago #

    I was going to suggest the same thing, since post/page thumbnails exist as a feature now, it seems like the obvious choice.

    And yes i removed my name from the title, the title indicates what the thread is about, it doesn't serve the thread by having my name there, and like RVoodoo said above, there are others here that can offer advice, by directing your question at me specifically you are potentially diverting away help that others may want to give/offer.

    It's not a problem, i just felt the title only need be descriptive of the question being asked, which isn't necessarily specific to me and my answers (or at least it need not be).

    The advice above is good, but if you have a problem following the information, i'm still here to help.. ;)

  11. rajesh0228
    Posted 6 years ago #

    RVoodoo, thanks 4 those suggestions. Let me 1st go thru them properly before implementing them.

    t31os_, so you've the power 2 modify thread titles.Never knew that. The reason I'd inserted your name was obvious. I was desperate 4 someone to reply to my need. I'd waited 4 a long time. I'd stumbled upon that thread in which t31os_ had replied 2 a similar need....so I thought why not send a SOS to you.;)

    In any case, I'll keep you gentlemen (or gentlewomen;)...I do not know) informed about my progress in this matter.

  12. Mark / t31os

    Posted 6 years ago #

    Like i said it's not a problem, you're more then welcome to direct questions at me, i just felt you might be alienating others from joining in and offering advice by directing questions at me specifically.. (the title only need serve as a description of the thread content).

    You're welcome to call me Mark if you prefer .... ;)

    And sure, please do let us know how you get on... :)

  13. rajesh0228
    Posted 6 years ago #

    I was going thru RVoodoo's & Mark Jaquith's codings...but I did not notice any reference 2 any path to an image. Why is it so?

  14. Rev. Voodoo
    Posted 6 years ago #

    the thumbnail is inserted into each post from the editor. Once you implement the functions.php portion of the above code, you get a box in your editor that allows you to attach a thumbnail to the post. Then the_post_thumbnail in index.php calls that thumbnail

    that way you get a unique thumbnail for each post

    you can also set up to have a default image if you like, in case you don't attach a thumbnail to the post but still want a default icon beside the title

    that would look like this:

    if ( has_post_thumbnail() ) {
         the_post_thumbnail('title-image', array('class' => 'titleImage', 'alt' => 'Title Icon'));
         } else {
         echo "<a href='" . get_permalink() . "'><img src='" . get_bloginfo('template_directory') .
        "/images/DefaultIcon.png' alt='Default Title Icon' title='Default Title Icon' class='titleImage' /></a>"; }

    which would load an image named DefaultIcon.png from your images directory in your theme, and display it, if you haven't selected a thumbnail for that post

  15. rajesh0228
    Posted 6 years ago #

    RVoodoo, you are right! That is what is stated at the top of Mark Jaquith's site. Now I understand. I'll try it out later.

  16. Rev. Voodoo
    Posted 6 years ago #

    once you get the hang of it.....it's pretty cool. I use it to display various images of diffent sizes on my posts, and single.php page, as well as on another website

  17. rajesh0228
    Posted 6 years ago #

    RVoodoo, I can't see the Post Thumbnail UI for both Post and Page after adding this in functions.php:

    add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts
    add_theme_support( 'post-thumbnails', array( 'page' ) ); // Add it for pages
    set_post_thumbnail_size( 50, 50 );

    I did refresh my admin login page. I am using the default theme in WP 2.9.2.
    Did I miss a step?

  18. Mark / t31os

    Posted 6 years ago #

    Click screen options and see if it's listed there and unchecked (of course it shouldn't be, but worth checking)..

    Also recheck the functions file, make sure the changes you made did stick and are present in the file.

  19. rajesh0228
    Posted 6 years ago #

    Mark, sadly it's not listed in Screen Options. And of course, the changes are still their in functions.php.

    What next?!!!

  20. Mark / t31os

    Posted 6 years ago #

    Just went to test my 2.9.2 installation just to confirm, i placed the following at the top of the functions file..

    add_theme_support( 'post-thumbnails' );

    Perhaps the issue is with how you're registering the support, what you have above, should be for when you want to use one or the other (posts OR pages), i don't think they're intended to be used together like that.

    Try what i've used above, assuming you want it for both pages and posts..

  21. rajesh0228
    Posted 6 years ago #

    Ok Mark, I did what you wanted me to. The difference is that I can now see Post Thumbnail in Screen Options. But where's the UI?

  22. Mark / t31os

    Posted 6 years ago #

    Do you see a "Post Thumbnail" box down the righthand side?

    You should see a box with titled "Post Thumbnail" containing the text.. "Set thumbnail"..

  23. rajesh0228
    Posted 6 years ago #

    Yes Mark, I can see it. I selected an image from my Media library & clicked Use as thumbnail.

    What next? Do I use these codes as stated in your site:

    1 <?php
    2 if ( has_post_thumbnail() ) {
    3 // the current post has a thumbnail
    4 } else {
    5 // the current post lacks a thumbnail
    6 }
    7 ?>

    the_post_thumbnail() outputs the Post Thumbnail, if it exists (in the loop):
    1 <?php the_post_thumbnail(); ?>

    But how 2 use them?

  24. Rev. Voodoo
    Posted 6 years ago #

    <?php the_post_thumbnail(); ?>

    added to your index.php near the code that calls up the title should display your thumbnail (this is the simplest code....we can work on adding more once your thumbnail is showing)

  25. rajesh0228
    Posted 6 years ago #

    RVoodoo, I added this -

    <?php the_post_thumbnail('title-image', array('class' => 'titleImage', 'alt' => 'Title Icon'));?>

    in index.php before the code that calls up the title. I can see my thumbnail. But I want 2 reduce the dimension, therefore I modified this code in functions.php:

    set_post_thumbnail_size( 30, 30);

    But this is not working! The dimension is as it was.

  26. rajesh0228
    Posted 6 years ago #

    Ok RVoodoo, i made this alteration-


    <?php the_post_thumbnail('title-image', array('class' => 'titleImage', 'alt' => 'Title Icon'));?>

    [The image was very big]

    <?php the_post_thumbnail(); ?>

    After this I can control the image size thru:

    set_post_thumbnail_size( 30, 30);

    But if you look at my site, the image is far away from my title. I want it 2 be just 2 the left of my post-title. How 2 do it?

  27. Rev. Voodoo
    Posted 6 years ago #

    that's where you'll need to play with css a bit.....

    I'm just guessing here....it may take a bit more, but you are using the default theme....so your title stuff looks like: <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    so I'd bet if you just added like this(the thumbnail stuff, wrapped ina class)

    <div class="titleThumb"><?php the_post_thumbnail(); ?></div><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    then add to your style.css

    .titleThumb {
        float: left;
        margin-right: 5px;

    it should help align things...again, I have no way of testing this on the default theme right now....so I'm kind of guessing. You may need to play with things a bit

  28. Mark / t31os

    Posted 6 years ago #

    Move the code next to the title..

    Take this code.

    <?php the_post_thumbnail(); ?>

    And place it before..

    <h2><a href="<?php the_permalink() ?>">  etc..

    Right now it's sat outside the post element ..

  29. Mark / t31os

    Posted 6 years ago #

    Had a feeling you'd reply mate ... :) I nearly didn't .... lol, i should of waited a few more minutes..

  30. Rev. Voodoo
    Posted 6 years ago #

    Had a feeling you'd reply mate

    as you are well aware....I'm getting rather familiar with the thumbnails!! ;)

Topic Closed

This topic has been closed to new replies.

About this Topic