• Hi all,

    I’m trying to link a title and authors name from my front page (News reel). I have no problem linking them, but styling the links seems impossible.

    I link them as follows:
    <a href="<?php the_permalink(); ?>" rel="bookmark"> <h1><?php the_title(); ?></h1></a>

    The styling I then have is:
    .main-text h1 a:hover{ text-decoration: underline; }

    No dice. I’ve tried a few different things and get nothing working.

    http://www.mmamount.com

    Any help is appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello CombatPost,

    If you are using the following styling:
    .main-text h1 a:hover{ text-decoration: underline; }

    This is trying to underline a hyperlink that you hover over.

    Try removing the “a:” -it will then underline regardless if it’s a hyperlink.

    Thread Starter CombatPost

    (@combatpost)

    Hi Arncus,

    Thanks for the reply, but that doesn’t work either!!

    When I use <?php the_author_posts_link(); ?> in the same way, it underlines on hover. Is there a way to auto link that title?

    Like <?php the_title_posts_link(); ?>

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Your HTML is not nested properly if you are using that code.

    <h1>
      <a href="<?php esc_url( the_permalink() ); ?>" rel="bookmark">
        <?php the_title(); ?>
      </a>
    <h1>

    Should be the code if you want the CSS to take effect right. The reason it is not working is because you have the h1 tag inside of the anchor ( a ) tag. That would mean your CSS would be something like:

    a:hover h1 {
        /* CSS goes here */
    }
    Thread Starter CombatPost

    (@combatpost)

    Thanks for your reply Jose.

    I have tried it both ways, inside and outside the anchor tag, and changed the CSS accordingly but no change.

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Have you tried clearing your cache? I was able to apply the rule:

    .main-text a:hover {
        color: blue;
        text-decoration: underline;
    }

    Thread Starter CombatPost

    (@combatpost)

    Hi Jose,

    Yeah I managed to fix it with the info you provided.

    I now have h1 outside the anchor tags and have the CSS as h1 a{. . . and that works perfectly.

    Any help on another problem, though? When I call for the title, I call first for the featured headline as follows.

    <?php if(get_post_meta($post->ID, "mvp_featured_headline", true)): ?>
    
    				<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php echo get_post_meta($post->ID, "mvp_featured_headline", true); ?></a></h2>
    
    				<?php else: ?>
    the title. . .

    The CSS is NOT working for when the article is using a featured headline, but is working when using the title.

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Unfortunately you will have to seek CSS help from a dedicated CSS forum. Most volunteers may/may not be able to further help you with it. All I can really tell you is that odds are your CSS selectors may not be right. 🙁

    Thread Starter CombatPost

    (@combatpost)

    Ok Jose, thanks alot for the help 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘CSS not working for permalink’ is closed to new replies.