Support » Fixing WordPress » html style tag doesn't work on php code?

  • I can’t get the following to work:

    <span id="featured-excerpt"><?php the_excerpt(); ?></span>

    The CSS style will work for anything before or after the php for excerpt, but the excerpt itself refuses to be styled. The only way I seem to have any success is using this approach, where I try to place the php inside the span tag. But it creates a new single-space blank line after the php ouput….

    <span id="featured-excerpt" <?php the_excerpt(); ?></span>

    Any pointers would be appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Please post a link to a page where this situation exists.

    I would post a link, but it is a non-public development version on my local machine. I am using a child theme of the oxygen theme with custom css in the child theme’s CSS file.

    Per my note above, the problem is that the php is resisting being styled. When I wrap the above-mentioned php script with span tags, and add some borders, then what happens is I’ll get one line with a blank space in a border box, then a line with the php excerpt output (but with no styling applied) and then another line with another blank space inside the CSS border box.

    Michael

    (@alchymyth)

    Forum Moderator

    try working with a browser inspection tool such as Firebug to investigate which styles are overwriting your span css class.

    the_excerpt() automatically wraps the result in a html paragraph tag which might get styled in your theme.

    @alchymyth – yes – this is what the issue was. I solved the issue with exactly the approach that you have suggested. When inspecting the element I saw that excerpt() wraps the output in paragraph tags per your comment. i.e. my styles were being overridden. Problem is now solved. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘html style tag doesn't work on php code?’ is closed to new replies.