Support » Theme: Tiny Framework » A help with PHP related to Tiny framework

  • Resolved Goodwrk

    (@goodwrk)


    Hi Tomas,

    I created a php code to change color of two words of site title based on php code I found on web.

    Can you have a look at it and tell me if it will work?

    Can I write to your email?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Goodwrk

    (@goodwrk)

    //filter first bloginfo instance
    
    add_filter( 'body_class',
        function ( $class )
        {
            add_filter( 'bloginfo', 'modify_second_and_third_words', 2, 1)
            return $class;
        }
    );
    
    function modify_second_and_third_words( $output, $show)
    {
        static $counter = 0;
        
        // Target the "name" part:
        
        if( 'name' === $show )
        {
            // Target first instance:
            if( 1 === ++$counter )
            {
                remove_filter( current_filter(), _FUNCTION_ );
                
                // Modify second and third words of the blog title:
                $title = explode( ' ', $output );
                if( count( $title) > 0 )
                {
                    $title[1,2] = sprintf( '<span>%s</span>', $title[1,2] );
                }
                $output = join( ' ', $title );
                
            }
        
        
        
        }
        return $output
    }
    

    This is php code. After that I added css from that webpage, but after that my website didn’t show. Can you point out what part of this code is wrong?
    My site title consists of three words.

    Theme Author Tomas Mackevicius

    (@tomasm)

    I’m sorry, but it is not right way to do. You can use Cuztomizer and just pick a color with color picker or you use CSS to assign colors. So in every situation you use right tool.

    Goodwrk

    (@goodwrk)

    My site title consists of three words. For example, if I want the first word to be white and other two to be green, I can’t do that with Customizer.
    Customizer only changes to one colour.

    Goodwrk

    (@goodwrk)

    Thomas, I found some CSS to do this.
    I’ll try it tomorrow.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.