WordPress.org

Ready to get started?Download WordPress

Forums

CSS not working for permalink (9 posts)

  1. CombatPost
    Member
    Posted 9 months ago #

    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.

  2. arncus
    Member
    Posted 9 months ago #

    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.

  3. CombatPost
    Member
    Posted 9 months ago #

    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(); ?>

  4. Jose Castaneda
    Member
    Posted 9 months ago #

    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 */
    }
  5. CombatPost
    Member
    Posted 9 months ago #

    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.

  6. Jose Castaneda
    Member
    Posted 9 months ago #

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

    .main-text a:hover {
        color: blue;
        text-decoration: underline;
    }
  7. CombatPost
    Member
    Posted 9 months ago #

    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.

  8. Jose Castaneda
    Member
    Posted 9 months ago #

    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. :(

  9. CombatPost
    Member
    Posted 9 months ago #

    Ok Jose, thanks alot for the help :)

Reply

You must log in to post.

About this Topic

Tags

No tags yet.