How to add style to a php snippet

In my wordpress site I have

<?php wp_loginout(); ?> 

which produces

Read More
<a href="http://example.com/wp-login.php">Log in</a>

I want to add the following style to the a tag

style="color:white;"

I don’t know php. Would I try find the php and then add it somehow? And how would I add it to the php?

Related posts

4 comments

  1. Use below code:-

    <div id='anchorStyle'>   <!-- define div  -->
      <?php wp_loginout(); ?> 
    </div>
    

    CSS

    #anchorStyle a{
      color:white;
    }

    Hope it will help you 🙂

  2. wp_loginout() has a filter hook ‘loginout’ which you could use to influence the output.
    Add a filter function to functions.php of your theme:

    add_filter('loginout', 'loginout_selector');
    function loginout_selector($text) {
    $selector = 'class="woo-sc-button"';
    $text = str_replace('<a ', '<a '.$selector, $text);
    return $text;
    }
    

    Ref: http://codex.wordpress.org/Function_Reference/wp_loginout

  3. In functions.php replace/add this filter

    add_filter( 'wp_nav_menu_secondary_items','wpsites_loginout_menu_link' );
    
    function wpsites_loginout_menu_link( $menu ) {
        $loginout = '<li class="myNewClass">' . wp_loginout($_SERVER['REQUEST_URI'], false ) . '</li>';
        $menu .= $loginout;
        return $menu;
    }
    

    fore reference: http://codex.wordpress.org/Function_Reference/wp_loginout

  4. you can’t style the php. The a tag is the tag you should style (html).

    if you want to add your style to the a tag best practice is to find/create the file which has extension .css or create a file called (name).css

    Simple way to style all your a tags is

    a {
    
    color: white;
    
    }
    

    Again, this styles all a tags and I don’t know the entire code.

    If you would want to specify which a tag gets which colors. Read up on CSS and adding class/id or nested elements.

Comments are closed.