• Hello everybody.
    Is it possible to select every single word in page titles (or menu items)?
    I need this to have a menu like this:

    Home -> is red

    About -> is red

    Info Service -> info is red and service is white

    Thank you in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • are you selling christmas candy? or barber poles? lol

    wordpress has filter hooks to influence the output of some of its functions.
    https://codex.www.ads-software.com/Plugin_API/Filter_Reference

    snippet how to use this on the title of posts/pages
    (this needs to be added to functions.php of your theme:

    add_filter('the_title','colorize_title');
    function colorize_title($out) {
    // if(in_the_loop()) : //optional to restrict the effect to some ares
    // see: https://codex.www.ads-software.com/Conditional_Tags ;
    $bits = explode(' ',$out);
    $i = 0;
      foreach($bits as $bit) {
      $bits[$i] = '<span class="bit-'.$i.'">'.$bits[$i].'</span>';
      $i++;
      }
    $out = implode(' ',$bits);
    // endif;  // closes the optional if statement
    return $out;
    }

    this wraps each word of a post/page title into a span with a css class .bit-0, .bit-1, and so on

    styling in style.css (styling the hover state is optional, but fun):

    span.bit-0 { color: #f00; }
    a:hover span.bit-0	{ color: #fff; }	
    
    span.bit-1 { color: #fff; }
    a:hover span.bit-1	{ color: #f00; }

    and so on.

    Thread Starter 2olive

    (@2olive)

    WOW!!! Alchymyth…you are really a MYTH!!!!

    Thank you so much!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to select words in page title’ is closed to new replies.