ThemeShaper Forums » Thematic

[closed]

looking for <div id="blog-title">

(11 posts)
  • Started 4 years ago by Hans Martin
  • Latest reply from em hr
  • This topic is resolved
  1. Hans Martin
    Member

    Hi,

    I'm working with the childtheme photolover,

    and I'm trying to change the color in the blog-title so it has two colors.

    but I can't find out wich php file contains this <div id="blog-title">

    thanks

    Posted 4 years ago #
  2. To change the color you should be able to get by on just CSS w/o doing any php. Except that I am not sure what you mean by wanting to use 2 colors?

    I did something where I filtered my blog title so that I could add spans around certain bits and style those accordingly. I don't if that is what you are trying to do, but here is the gist of what I did.

    function child_blogtitle() { 
    
    $title = get_bloginfo('name');
    $title = str_replace('WORDS','<span class="colorchange">WORDS</span>',$t);
    
    <div id="blog-title"><span><a href="<?php bloginfo('url') ?>/" title="<?php bloginfo('name') ?>" rel="home"><?php echo $title ?></a></span></div>
    
    <?php }
    
    add_filter('thematic_blogtitle','child_blogtitle');

    btw- the function, thematic_blogtitle(), can be found in the library/extensions/header-extensions.php file of thematic. I like to poke around in the extensions folder to find the function I want to use... then I copy it to my functions.php file, make the adjustments I want and then filter it in.

    EDIT 2/8/2012: this post is old and my filter function is awful, AND there is not thematic_blogtitle filter. to achieve this you'll need to use the override functionality.

    function childtheme_override_blogtitle() {
    $title = get_bloginfo('name');
    $title = str_replace('Test','<span class="colorchange">Test</span>',$title);
    ?>
    <div id="blog-title"><span><a href="<?php bloginfo('url') ?>/" title="<?php bloginfo('name') ?>" rel="home"><?php echo $title ?></a></span></div>
    <?php }
    Posted 4 years ago #
  3. Hans Martin
    Member

    Hi Helga, thanks for your reply.

    what I want to do is to have the letters in 2 different colors, as in first 4 letters black and the 5 last red.

    so I figured it would be something like this

    php

    <h1><span>Min</span> titel</h1>

    CSS
    h1 { color: green; }
    h1 span { color: red; }

    are your code doing the same thing?

    thanks again

    Posted 4 years ago #
  4. Ok, that is sort of what I thought you wanted... and what I did here: http://www.weighttrainingforwomentoday.com

    I didn't do it exactly as I wrote above but that is the general idea and (in theory) should work once you change the string replace function to match your title. I messed up above as my code uses the variable $t and I wanted to make that be $title so it would make more sense but then i forgot to change it in all places.

    $title = str_replace('Min','<span>Min</span>',$title);

    That will look in your title for Min and echo back <span>Min</span> in its place. You could add a class to the span ( I did since I used 2 or 3) but if you are only using 1 then it probably isn't necessary.

    Posted 4 years ago #
  5. Hans Martin
    Member

    Hi Helga,

    It didn't work out, I am a newbie in php..

    so here is what I did.

    I changed the <div id to <h1 id and thus...

    // Create the blog title
    // In the header div
    function thematic_blogtitle() { ?>

    <h1 id="blog-title" >

    <span></span>/"

    <h1><span>SPOR</span>MEDIA</h1>

    <?php bloginfo('name') ?></span></div>
    <?php }
    add_action('thematic_header','thematic_blogtitle',3);

    Many thanks Helga

    Posted 4 years ago #
  6. Did you try the code I gave you? I've edited it to fix my errors and pull in the name you seem to want to put a <span> around.

    function child_blogtitle() { 
    
    $title = get_bloginfo('name');
    $title = str_replace('SPOR','<span>SPOR</span>',$title);
    
    ?>
    
    <div id="blog-title"><span><a href="<?php bloginfo('url') ?>/" title="<?php bloginfo('name') ?>" rel="home"><?php echo $title ?></a></span></div>
    
    <?php }
    
    add_filter('thematic_blogtitle','child_blogtitle');

    Your code has a couple of problems that I can see right off the bat. It is best practice (I feel silly claiming to actually know best practices, but I digress) to name your child theme's functions something other than the thematic function names. Ex... the function in your child theme would be child_blogtitle. Not that you have to call it that, but I am pretty sure you need to call it something ELSE. Then if you want to add it as an action (say if you want to add it to a different hook) you must first REMOVE it from it's current location. Instead it looks like you want to be using;

    add_filter('thematic_function_you_want_to_change','your_replacement_version');

    so if you renamed your function name to child_blogtitle()

    and then use

    add_filter('thematic_blogtitle','child_blogtitle');

    you'll atleast be able to pull your function in. however, i do not understand what the rest of your code is trying to accomplish. as a cut and paste coder myself, i am going to suggest again you try my snippet to see if that will do what you want. Thematic by default doesn't put an h1 tag on the title, but you could wrap the header tags around the link in my snippet if you are determined to have an h1 tag there.

    good luck. i hope that helps.

    Posted 4 years ago #
  7. Hans Martin
    Member

    Hi Helga, thank you for being so patient with me ;-)

    I added in your code and gave it the color blue in my css.

    I kept my <h1 id so you can see what it did. have a look.

    http://www.freeyourneck.dk/hans/

    It is clearer to me now about the child blogtitle, now I'm trying to figure out how it should be in my css?

    thanks a bunch

    Posted 4 years ago #
  8. Hans Martin
    Member

    Still trying to figure out the css thing?

    ;-)

    Posted 4 years ago #
  9. I don't understand what you are trying to do now. Did you want SPORMEDIA written twice? I see it as a red SPOR, black MEDIA.... on top of a blue SPORMEDIA. post the code you are using.

    Posted 4 years ago #
  10. Hans Martin
    Member

    I want SPORMEDIA written once in red and black.

    Just wanted to show you what I did with my H1 (which now shows as the red and black 'SPORMEDIA')

    the code I'm using is.

    // Create the blog title
    		// In the header div
    		function thematic_blogtitle() { ?>
    
    		    		<h1 id="blog-title"  >
    
    		    		<span></span><a>/" 
    
    		    		<h1><span>SPOR</span>MEDIA</h1>
    
    		    		<?php bloginfo('name') ?></a></span></div>
    
    		<?php }
    		add_action('thematic_header','thematic_blogtitle',3);
    
    function child_blogtitle() { 
    
    $title = get_bloginfo('name');
    $title = str_replace('SPOR','<span>SPOR</span>',$title);
    
    ?>
    
    <div id="blog-title"><span><a>/" title="<?php bloginfo('name') ?>" rel="home"><?php echo $title ?></a></span></div>
    
    <?php }
    
    add_filter('thematic_blogtitle','child_blogtitle');
    Posted 4 years ago #
  11. Hi Hans,

    Sweet, I'm glad you resoved your problem and shared your solution with us! Next time, try using the backtick(`) when you post code.

    Cheers,
    Gene

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.