WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Help on Image for each post title

[Resolved] Help on Image for each post title

Viewing 15 replies - 1 through 15 (of 50 total)
  • 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?

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

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

    Give me a few minutes and i’ll see what i can do to help.. 😉

    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.

    EDIT:
    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?

    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.

    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?

    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?

    @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.
    http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/

    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:

    // THIS IS THUMBNAIL SUPPORT
    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

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

    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.

    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… 🙂

    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?

    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:

    <?php
    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

    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.

    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

Viewing 15 replies - 1 through 15 (of 50 total)
  • The topic ‘[Resolved] Help on Image for each post title’ is closed to new replies.