WordPress.org

Support

Support » Themes and Templates » [Resolved] Need help for Title css and image

[Resolved] Need help for Title css and image

  • 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

Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi

    @esmi

    Forum Moderator

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

    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

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

    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

    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

    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

    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); ?>

    Sure:

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

    Peter

    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

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Need help for Title css and image’ is closed to new replies.
Skip to toolbar