With a multi-user blog, how can I add a posted by Some Author line, or something similar, at the top of each post, as in this blog? I assumed this should be something very basic, and there should be a setting for it, but I can't seem to find it anywhere.
3 Answers
A plug-in might use the_content
filter to append / prepend this, but if you're a theme author or otherwise are able to edit the the theme templates directly.
In this case you want to edit your theme's single.php
. (You can always check which template file is being used by a particular page using this answer: https://wordpress.stackexchange.com/a/10565/9364).
single.php
is used for single posts, and other post types if they do not have their own template (you see how WordPress decides what template to use here).
In single.php
you should find something like
<?php get_template_part( 'content', get_post_format() ); ?>
Which includes another file depending on the post's format. For a normal post, this will be content.php
. (Please note this may vary by theme - the upshot is that you want to find where it calls the_content()
) - the_content()
is what displays the post content.
Below that you want to add something like:
the_author();
(see codex). Check the TwentyTwelve theme for more 'involved' example.
-
I posted the solution that solves this in my case, but this answer is more general (not twenty-twelve-specific) so I'll accept this one.– SzabolcsCommented Jun 6, 2013 at 9:40
With the twenty-twelve theme, the following is in style.css
:
.single-author .entry-meta .by-author {
display: none;
}
This was the source of the problem and it needed to be commented out.
-
Yep, worked for me. Just in case anyone else has trouble finding it: Appearance > Editor > Select Stylesheet (style.css) from the right hand menu. Commented Sep 2, 2018 at 5:28
Short answer, but it sounds like what you want is the_author
.
The Codex page for that function has an example of what you want, I think:
<p>This post was written by <?php the_author(); ?></p>
You will have to edit that into one or more of your theme templates but without having the code for the theme I can't say where.