Forums

[resolved] changing the link color in a post (27 posts)

  1. jvazjr
    Member
    Posted 2 years ago #

    how can i change the color of the link in my post??

    also, how can i make that link open in a new window?

  2. dbmartin
    Member
    Posted 2 years ago #

    Changing the color of a link is done via your CSS style sheet.

    There are several ways to make links open in new windows. I just wrote a tutorial on my blog about using jQuery to open external links in a new window. You can check it out here if you'd like.

  3. jvazjr
    Member
    Posted 2 years ago #

    where in the style sheet

  4. jvazjr
    Member
    Posted 2 years ago #

    that link you gave me is way too confusing

  5. jvazjr
    Member
    Posted 2 years ago #

    where is the help???

  6. dbmartin
    Member
    Posted 2 years ago #

    In your style sheet look for a:link, a:visited, a:hover, a:active.

    As for the tutorial, it takes you step by step and explains everything.

    If you'd rather just hack the links to get them to open in a new window and don't care about being standards-compliant, then you can just add target="_blank" to your links like so:

    <a href="url_of_link" target="_blank" title="title of link">link text</a>

  7. jvazjr
    Member
    Posted 2 years ago #

    for the color change,where do i find the info to edit??

    you said a:link, a:visited, a:hover, a:active???

  8. jvazjr
    Member
    Posted 2 years ago #

    i dont see anything like this in the content area

  9. jvazjr
    Member
    Posted 2 years ago #

    here is my blog

    jvazjrsblog.com

  10. dbmartin
    Member
    Posted 2 years ago #

    You have to look in your CSS stylesheet; your style.css file. Your links are currently set to:

    a {
      color: #727248;
      text-decoration: none;
      }
    
    a:hover {
      color: #727248;
      text-decoration: underline;
      }

    In your WP Dashboard left navigation menu open the built-in file editor (Appearance » Editor) and choose your CSS stylesheet to edit. Scroll until you see the code I typed above and change the color to whatever you want.

  11. jvazjr
    Member
    Posted 2 years ago #

    change it for both?

  12. jvazjr
    Member
    Posted 2 years ago #

    this will only change the links in the posts right?

  13. dbmartin
    Member
    Posted 2 years ago #

    No, it will change all links because you don't have links within posts styled separately from other links. If you only want links within the post content to be changed then you need to add the following to your stylesheet:

    .postContent a {
      color: #whatever color you want;
      text-decoration: none;
      }
    
    .postContent a:hover {
      color: #whatever color you want;
      text-decoration: underline;
      }
  14. jvazjr
    Member
    Posted 2 years ago #

    add both correct??

  15. jvazjr
    Member
    Posted 2 years ago #

    where do i add them?

  16. dbmartin
    Member
    Posted 2 years ago #

    In your WP Dashboard left navigation menu open the built-in file editor (Appearance ยป Editor) and choose your CSS stylesheet to edit.

  17. jvazjr
    Member
    Posted 2 years ago #

    i know that part

    where do i add that code in the style sheet?

  18. jvazjr
    Member
    Posted 2 years ago #

    well?

  19. jvazjr
    Member
    Posted 2 years ago #

    can anyone else help me??

  20. Nowhere Man
    Member
    Posted 1 year ago #

    .postContent a {
    color: #whatever color you want;
    text-decoration: none;
    }

    .postContent a:hover {
    color: #whatever color you want;
    text-decoration: underline;
    }

    This didn't work when I tried it :(

  21. alchymyth
    The Sweeper
    Posted 1 year ago #

    @Nowhere Man:

    chances are that your theme uses a different css class for the post.

    theme?
    link?

    try to look into index.php or single.php of your theme, and see if you can identify the class of your post area - something vaguely similar to
    <div class="entry"> <?php the_content(); ?> </div>

    where you might find the class you are looking for in place of 'entry' in the above example.

  22. Nowhere Man
    Member
    Posted 1 year ago #

    Thanks, alchymyth,

    My theme is K2. I'm trying to change the color of my post's links.
    When I look in index.php I see:

    <?php get_header(); ?>

    <div class="content">

    <div id="primary-wrapper">
    <div id="primary">
    <div id="notices"></div>

    <?php /* K2 Hook */ do_action('template_primary_begin'); ?>

    <?php if ( '1' == get_option('k2rollingarchives') ): ?>
    <div id="dynamic-content">

    If there was a color code I would know what to do. But this is all I see. In single.php it's the same.

    Any suggestion as to what to specifically change? Thanks!

  23. James
    Happiness Engineer
    Posted 1 year ago #

    In the style.css file, look for this section:

    a {
            color: #27d;
            text-decoration: none;
            }

    On an unedited style.css from K2 1.0.3, those are lines 1035 - 1038. Just change the "color" attribute.

  24. Nowhere Man
    Member
    Posted 1 year ago #

    Thanks, Macmanx, but I tried that and it doesn't work. That's the color of my links on the sidebar. [My editor doesn't show lines, of course] I'm just trying to change the link colors that apear on the posts. It's a horrible red color.

  25. James
    Happiness Engineer
    Posted 1 year ago #

    If you're talking about http://venicebeachartists.com/ the links are only red after they have been visited. They're blue just like the sidebar links if they are unvisited. To change the visited links color, look for this section:

    .entry-content a:visited {
    	color: #b41;
    	}

    On an unedited style.css from K2 1.0.3, those are lines 1040 - 1042. Just change the "color" attribute.

  26. Nowhere Man
    Member
    Posted 1 year ago #

    Thank you, macmanx, it works great!

  27. James
    Happiness Engineer
    Posted 1 year ago #

    You're welcome!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.