• Resolved dominoeffect

    (@dominoeffect)


    Hi all,

    I wanted to use this code on the front page of my blog:

    <strong><?php the_author(); ?></strong>: <?php the_excerpt(''); ?>

    …in order to look something like this:

    Joe Bloggs: Lorem Ipsum etc […]

    But anooyingly the_excerpt text always begins on a new line!

    Is anybody aware of a way this can be changed, a relatively safe hack perhaps?

    Thanks

Viewing 15 replies - 1 through 15 (of 15 total)
  • A link to a page demonstrating the problem might help…

    Thread Starter dominoeffect

    (@dominoeffect)

    Hi emsi,

    It will happen on any website: if you put content before of after the_excerpt, the excerpt puts itself on a new line.

    E.g. the code:

    before<?php the_excerpt(''); ?>after

    will display the following:

    before
    the excerpt content yadda yadda...
    after

    Any help on how to remove this line break would be most appreciated.

    The website in question is being developed on a private server so I’m afraid I can’t offer a link.

    It will happen on any website

    Yes – I’m aware of that. The_excerpt is wrapped in <p></p> tags by design. The obvious solution would be to look at reformatting the display using CSS but, without seeing the page, I can’t tell if that’s possible.

    Thread Starter dominoeffect

    (@dominoeffect)

    The obvious solution would be to look at reformatting the display using CSS but, without seeing the page, I can’t tell if that’s possible.

    I’ve upped the theme here — ignore the broken images and so on as this page is contentless, unlike the actual site. How do you think CSS might be used?

    Thank you.

    You’ve password protected the page. Does it contain the kind of content you want to display – ie excerpt & author?

    Thread Starter dominoeffect

    (@dominoeffect)

    Oh sorry, please try again now. ‘Latest posts’ section is the relevant part. Yep excerpt and author are there.

    Try adding:

    .postsnippet h2 {
    display:inline-block
    float:left;
    }

    to the bottom of style.css.

    Thread Starter dominoeffect

    (@dominoeffect)

    Thanks for the response, I’ve implemented it on the above link but unfortunately it hasn’t had an effect.

    Any further ideas are most welcome ??

    (Sorry for the late response, I haven’t been at my comp all weekend.)

    There’s a semi-colon missing in the CSS I provided – sorry. Try:

    .postsnippet h2 {
    display:inline-block;
    float:left;
    }
    Thread Starter dominoeffect

    (@dominoeffect)

    Afraid that still isn’t working, thanks though.

    Sorry – wrong element. Try:

    .postsnippet strong {
    display:inline-block;
    float:left;
    }
    Thread Starter dominoeffect

    (@dominoeffect)

    That still doesn’t work; actually though the previous code did work by wrapping the author name to the title, but it was indeed the wrong element.

    To be honest, I think you need better markup. Surrounding the author name with generic <strong></strong> tags (especially with the colon being outside of these tags) isn’t helping. Something like:

    <div class="the-author"><?php the_author(); ?>:</div> <div class="postcontent"><?php the_excerpt(''); ?></div>

    might be a lot easier to style.

    Thread Starter dominoeffect

    (@dominoeffect)

    Thanks, I’ll give that a shot and post the results.

    Thread Starter dominoeffect

    (@dominoeffect)

    This turned out to be quite easy actually. If I were more experienced with css I might have got it sooner. I code I went with, (which worked perfectly), was this:

    <span style="display:inline-block;float:left;"><a href="<?php the_permalink() ?>"><?php the_author(); ?>:&nbsp;</span><?php the_excerpt(''); ?></a>

    Thanks again for your help.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Must the_excerpt start with a line break?’ is closed to new replies.