WordPress.org

Forums

[resolved] There is no attribute "excerpt" - Help to solve this validation error (8 posts)

  1. lyvyoo
    Member
    Posted 2 years ago #

    Hello,

    I try to solve this validation error:

    there is no attribute "excerpt"

    The line affected is located in index.php:

    <h2><a style="font-size:12px" href="<?php the_permalink(); ?>" excerpt="<?php the_excerpt(); ?>"><?php the_excerpt(); ?></a></h2>

    What is wrong in my code?

    Thank you,

  2. There is no excerpt attribute. I think you have it confused with the title attribute.

    <h2>
        <a style="font-size:12px" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    </h2>
  3. lyvyoo
    Member
    Posted 2 years ago #

    Thank you,
    Your code isn't ok for me beacause make to disappear my post excerpt, when you are with the mouse over the photos - http://www.liviufratila.ro/

  4. alchymyth
    Forum Moderator
    Posted 2 years ago #

    simply remove it;

    example:

    <h2><a style="font-size:12px" href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a></h2>
  5. lyvyoo
    Member
    Posted 2 years ago #

    alchymyth Thank you! It worked!

  6. lyvyoo
    Member
    Posted 2 years ago #

    Now, in this new line that solve the topic problem, I have a secondary and last error:

    "document type does not allow element "p" here; missing one of "button", "map", "object", "ins", "del", "noscript" start-tag" (W3C Validator)

    But I don't see "p" in php code...

    <h2><a style="font-size:12px" href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a></h2>

  7. alchymyth
    Forum Moderator
    Posted 2 years ago #

    the_excerpt() automatically wraps the text into a <p> tag;

    try and use this instead:

    <h2><a style="font-size:12px" href="<?php the_permalink(); ?>"><?php echo get_the_excerpt(); ?></a></h2>

    http://codex.wordpress.org/Function_Reference/get_the_excerpt

  8. lyvyoo
    Member
    Posted 2 years ago #

    Thank you again! You help me a lot to validate the html.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.