Adding Byline to posts
Currently, with my theme of choice (WP-Andreas01) I don’t have any byline on my posts. I want to add a byline, but I”m sure that when I do, it will go to the bottom with the rest of the post info. Is there a way to add a byline and make it post under my title?
There’s a plugin called Add Signature that adds a signature to the end of posts. I have edited it for my own use to add the beginning of the post (after the title but before the post content). If you’d like I can send you my version.
If this is just to add the author name to the post, just slip in:
<?php the_author(); ?>
right after where the post title appears in the template, typically in an
<h2>element. Here’s what it looks like in the default theme:
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
Ok, I tried it just like Kafkaesqui showed, but it didn’t work. Here’s the top half of the Single Post Template. I’m hoping that’s where it’s supposed to go, but look at this and let me know what I’m doing wrong.
<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_author(); ?> (this is what I added)
<?php the_content(‘<p>Read more »</p>’); ?>
I don’t see anything wrong with your code as shown above. At least, nothing that should cause a problem outputting the author of the post. To avoid X/HTML validation issues, you might want to place it in a
<div>element, but that’s for later.
You say your addition to the template didn’t work. So you’re not seeing anything between the post title and content on single post pages? Try a little change to the line:
<p>Posted by <?php the_author(); ?></p>
Then at least if you see the preceding text, we’ll know the change is occuring in the template.
Heh, Kafkaesquí to the rescue again! Could you please mark this as “resolved” then?
I changed my Single Post template to:
<h2>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></h2>
<p> by <?php the_author(); ?></p>
and there no change and the word ‘by’ did not appear.
I notice the Main Index Template already has:
<h2>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h2>
<small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small>
I’m not sure why the author isn’t appearing either in the Main or Single page.
Any help appreciated.
- The topic ‘Adding Byline to posts’ is closed to new replies.