dominoeffect
Member
Posted 1 year ago #
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
A link to a page demonstrating the problem might help...
dominoeffect
Member
Posted 1 year ago #
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.
dominoeffect
Member
Posted 1 year ago #
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?
dominoeffect
Member
Posted 1 year ago #
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.
dominoeffect
Member
Posted 1 year ago #
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;
}
dominoeffect
Member
Posted 1 year ago #
Afraid that still isn't working, thanks though.
Sorry - wrong element. Try:
.postsnippet strong {
display:inline-block;
float:left;
}
dominoeffect
Member
Posted 1 year ago #
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.
dominoeffect
Member
Posted 1 year ago #
Thanks, I'll give that a shot and post the results.
dominoeffect
Member
Posted 1 year ago #
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(); ?>: </span><?php the_excerpt(''); ?></a>
Thanks again for your help.