2

I can't get CSS styling to work on content returned from a wordpress php function:

<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 where I try to place the php inside the span tag, which hardly seems correct, and creates a new single-space blank line after the php ouput....

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

Any pointers would be appreciated.

21
  • 1
    Show us what you've got code-wise, otherwise we're like blind men in a minefield! Commented Oct 13, 2012 at 0:23
  • Sorry - I hadn't yet figured out the code button - I've edited the post so that the code is now visible. Commented Oct 13, 2012 at 0:25
  • What is the intended output of the_excerpt(); ? What are you expecting to be rendered/displayed? It's entirely valid to render php output between any style-based tag. Commented Oct 13, 2012 at 0:28
  • 1
    @platplaas Between/enclosed by, not within unless the function is to do something other than display an excerpt. See the answer I gave and check the link if you haven't already. Commented Oct 13, 2012 at 0:42
  • 1
    @platplaas I mean, what is it that is actually on your page if you open it up in the browser and do view source. Commented Oct 13, 2012 at 0:43

2 Answers 2

1

In which case... Just looked at: http://codex.wordpress.org/Function_Reference/the_excerpt

It's entirely valid to:

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

or

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

EDIT (and given the comments):

Try removing the php function and render text, that way we'll know if this is a style or function issue:

<span id="featured-excerpt">Lord help us!</span>

How does it display? Does it display in your HTML output?

Sign up to request clarification or add additional context in comments.

2 Comments

yes - the 'lord help us' does display correctly per the intended CSS styling. Per comments in above thread - I discovered that the wordpress php function for excerpt returned the text in paragraph tags. I've modified my CSS to include paragraph tags as a child, and now it works as intended: #featured-excerpt p { border:blue dotted 3px; }
On a side note, what I find remarkable is that Wordpress don't mention inherited/included tags/styling anywhere in the codex description for the function. Poor show Wordpress.
1

the_excerpt functions is returned with paragraph tags. The best easy solution is call the_content function instead of the_excerpt

the_content provide all css you add in content box.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.