WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Need help for Title css and image (10 posts)

  1. xinfo
    Member
    Posted 4 years ago #

    Hi Guys

    1, i want show single title in 2 color like first half title in one color and rest half title in other color

    2, i have post set up like where post title show over the photo

    and background for the title black transparent image you can check .collegehumor.com (top 3 post )

    i am able to get transperent stuff in firefox but not in IE how i can fix this in IE

    note:black transprant is png image

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Some versions of IE don't support transparent pngs. Try using a transparent gif file instead.

  3. Peter Boosten
    Member
    Posted 4 years ago #

    Try using a transparent gif file instead.

    A gif file will look horrible though... Search Google for 'pngfix', you'll find several javascript based solutions.

    Peter

  4. xinfo
    Member
    Posted 4 years ago #

    okie well i search for pngfix well what about the title my first question

  5. Peter Boosten
    Member
    Posted 4 years ago #

    What title are you referring to? The title of a post? Assuming this, ans assuming you're actually talking about the first half (in number of characters) of the title, then:

    I think it's possible, but you would have to extract the title from the post directly, split it in two, and apply to different classes to the concatenated strings. You cannot use the_title(), because it'll echo the title to your browser immediately, without you being able to modify.

    $title=$post->post_title;

    Will put the title in a variable called $title. After that you can determine the length of the title, split it in half with substr.

    I'll leave the rest up to you.

    Peter

  6. xinfo
    Member
    Posted 4 years ago #

    pboosten

    your right i am looking for post title solution , i am sorry i am not clear well

    well i am not big php developer i am trying myself, if u already cooked the code please paste the code

  7. Peter Boosten
    Member
    Posted 4 years ago #

    I haven't cooked anything up till now.

    Oke, in your single.php somewhere is a snippet like this:

    <?php the_title(); ?>

    change that to this:

    <?php
    $title=$post->post_title;
    
    $len=strlen($title);
    
    echo '<span class="titleleft">'.substr($title,0,$len/2).'</span><span class="titleright">'.substr($title,$len/2).'</span>';
    
    ?>

    In your style.css you should then add the following:

    .titleleft {
      color: #F00;
    }
    
    .titleright {
      color: #00F;
    }

    If you already have defined a titleleft and titleright class, please change the above to something of your choice. Furthermore, the colors are for demonstration purposes, please change them to your likings.

    Peter

  8. xinfo
    Member
    Posted 4 years ago #

    peter your code very well as wat i needed

    but i am not able to limit the title length

    this is my current code for title where 26 is number of charter to display in title it's possible to mix your title code along with my code ? so i can control the length of the title

    <?php echo dp_clean($post->post_title, 26); ?>

  9. Peter Boosten
    Member
    Posted 4 years ago #

    Sure:

    $title=dp_clean($post->post_title, 26);

    Peter

  10. xinfo
    Member
    Posted 4 years ago #

    peter i have to thank you so much for helping me out it working very well as i needed, thank you so much taking your time to help me out

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags