By default genesis post info includes the date the article was posted, an author link and comments. However every blog may have a different need of exactly what they want displayed here.
Some may not even want any of this information displayed. To remove the byline in genesis add the following code to your child’s theme functions.php
remove_action('genesis_before_post_content', 'genesis_post_info');
However, if you do want want a byline on your site but just want to change exactly what is displayed or in what order it shown, there is a filter available.
add_filter('genesis_post_info', 'custom_post_info'); function custom_post_info($post_info) { $post_info = __('By', 'genesis') . ' [post_author_posts_link] ' . __('on', 'genesis') . ' [post_date] [post_comments] [post_edit]'; return $post_info; }
The code above will change the output from the default byline:
by
To:
By
on
Aaron Courtney says
Thanks much for the above Chris! You can check out your syntax (with a bit of my modifications) in action on the blog pages.
Sam Baker says
Thanks! I used your tip to get rid of the date. I see there are other neat tricks I could use as well – I am sure to try out a few 🙂
Pushpendra Pal says
Thanks Christopher, I used this trick to remove byline from my blogs posts. Going to check other tutorials on your site.
Mike Gosling says
Crikey – I added the html above to my Focus functions.php and got an error message:
“Parse error: syntax error, unexpected $end in /home/emotmnet/public_html/wp-content/themes/focus/functions.php on line 50”
Now I’m locked out of my site as each time I login I get the same message above.
Have I ruined my site? Do I need to start over?
This is what I added:
add_filter(‘genesis_post_info’, ‘custom_post_info’);
function custom_post_info($post_info) {
$post_info = __(‘By’, ‘genesis’) . ‘ [post_author_posts_link] ‘ . __(‘on’, ‘genesis’) . ‘ [post_date] [post_comments] [post_edit]‘;
return $post_info;
}
Mike Gosling says
All good. I have restored my site by some ftp magic and Filezilla. I realize now that I inserted a piece of code for the Genesis theme into my Genesis Child Focus theme – it didn’t work!
Can you please advise my the code to insert into my Focus theme functions.php that will remove the date from my Focus theme?
Christopher says
You would want to make sure it’s after a ““. They tell when php code starts and end so the server can process it correctly. Place it at the bottom of your child themes functions.php before the “?>” if there is one; if not you can still put it at the end. If would like help, if you could use pastebin.org to post the contents of your functions.php I can show you exactly where to put it.
Mike Gosling says
Hey Christopher,
Thank you for your help. I have loaded my functions.php at http://pastebin.com/bZ2fNSiW
Please show me exactly where tp put the filter script.
Mike Gosling says
Hi, I’m wondering if you can assist with inserting this code. My functions.php does not seem to have a “?>”
Mike Gosling says
Hi Christopher,
Not sure why you have not answered my post. You say, “Place it at the bottom of your child themes functions.php before the “?>” if there is one; if not you can still put it at the end.”
My Focus theme functions.php does not have “?>” at the end.
I added the script as you suggested days ago and the site froze up, which resulted in my post above.
Am I missing something here? Am I required to pay a fee to get my script altered which I pasted at http://pastebin.com/bZ2fNSiW
Sorry, I just don’t get why you have replied to other posts here and not mine.
Please advise.
Christopher says
Try this, *Edit: http://pastebin.com/vg6jA8zn *
Sorry for not answering sooner, work got too crazy the other day and just started going back through my comments responding to any I missed.
Edit:
I found the issue. There were fancy quotes in the snippet. I have updated the code in the link above and should work correctly now.
Mike Gosling says
OK Christopher, Understand. Thanks for coming back to me on this. I’ve now added the following code to elminate the date and all is ok!
add_filter(‘genesis_post_info’, ‘custom_post_info’);
function custom_post_info($post_info) {
$post_info = __(‘By’, ‘genesis’) . ‘ [post_author_posts_link] ‘ . ‘ [post_comments] [post_edit]‘;
return $post_info;
}
Susanna says
I’m trying to remove the byline (author name and date) at the beginning of the post. So could I just paste this into simple hooks? remove_action(‘genesis_before_post_content’, ‘genesis_post_info’);
If yes, where in simple hooks?
Christopher says
This code is actually for the child themes function.php file. With simple hooks you can simply check a box labeled “Unhook genesis_post_info() function from this hook?” The plug-in allows easy removal of a lot of functions that have been put in through hooks.
Susanna says
Thanks. I found the box and checked it. But I still have the post date and author name above the blog post. Sorry for any trouble here. I thought I was a savvy gal. Is simple edits and easier place to do this?
Andrew says
I’m trying to change the byline in my copyblogger theme and add some social media share buttons to the right side where the comments link is now I copied the add_filter code above to the copyblogger functions file, but nothing is changing.
Right now my byline looks like this:
March 30, 2012 By Andrew Leave a Comment
But I’d like it to look like this:
March 30, 2012 By Andrew – Leave a Comment Facebook – Twitter share buttons
Andrew says
Never mind. I just noticed that the code to alter the post info is already in the functions file for the copyblogger theme.
Christopher says
Andrew, thanks for commenting. Yes, some child themes have already altered some the default genesis functions, so always want to look for that first.
Andrew says
I’m confused now, because I’ve tried altering the $post_info part of my functions file, but nothing is changing on my site. The variables also don’t seem to match what’s currently being displayed.
Here’s what in the function file:
$post_info = ‘by [post_author_posts_link] on [post_date] [post_comments] [post_edit]‘;
But as I said earlier my byline looks like this:
March 30, 2012 By Andrew Leave a Comment
Is it possible the byline is being set somewhere else in the copyblogger template?
Christopher says
It may be possible that it is being modified by a plugin. Try removing it all together with
the 20 will make the filter run later, can even set it at 100 to make sure it runs after all other modifications to the post info.
Andrew says
I found it. It’s in Genesis Simple Edits. Do you know if it’s possible to add facebook or twitter share buttons there? I started thinking about putting them in the byline when I was looking at the the Visual Hook Guide, because it has a twitter link on the right side of the byline.
Christopher says
For the twitter button I actually ended up creating a twitter plugin that displays the button with a shortcode and added that post info filter. Could do something simliar. I have a tutorial in draft that is over a year old. Maybe I should dust that off. Definitely possible though.
Troy Dunn says
This was very helpful! Thank you.