WordPress Post Meta Data Tutorial

Published by admin on



My new advanced WordPress course:
My new beginner WordPress course:

In this lesson we learn how to output the date (and control the formatting) as well as the author name and category.
To view a complete list of the WordPress lessons in sequential order visit:

Link to download .zip of theme files as shown in this video (note: this is not a “complete” WordPress theme yet and this download is only intended for educational purposes to dissect and review):

Sign up for my newsletter to receive periodic webDev tips, tricks, resources and coupons. Join the list at

Follow me on Twitter for updates and cat pics:

source


26 Comments

Neetha Alex · January 31, 2017 at 10:43 am

This is what i am searching for. thank you so much ,Great job 🙂

Rajni Nair · April 2, 2017 at 6:16 am

Thank you so much for this wonderful turorial series.

JonathanItzen · April 8, 2017 at 5:06 pm

Your tutorials are amazing. Thanks!

TheOriginReport · April 19, 2017 at 7:12 am

Hello Brad,

Quick question. When you write the code to get the category information starting on line 13, should we be extracting this functionality into a function inside the functions.php file or is it fine to keep it in this file? I assume we won't be re-using this code block elsewhere so I assume it is fine as-is, but I was just curious what the best practices would be in this and similar cases. Thanks and loving the series so far!

Yanka Dudenko · April 22, 2017 at 12:35 pm

I haven't tried other tutorials, but judging by the comments in all the videos yours are the best ones. I'm very lucky I landed on yours right away. So thorough and very understandable. I'm enjoying the process of building the site step-by-step even though I sometimes spend a couple of days trying to figure out where a mistake lies. Thank you Brad!!

rot rose · May 6, 2017 at 4:23 pm

this series of wp tutorials are really greatly helpful. want more….

tomxxi · May 9, 2017 at 11:33 am

Your tutorials are awesome, better than any others I've seen on these topics. Thanks!

SnoozlesLP · June 2, 2017 at 2:52 pm

I'm not sure if anybody still reads these but I'm getting access denied when clicking on the author link. Can someone help me with that?

Piero Dauber · June 30, 2017 at 11:32 am

your lesson are amazing but for this one if may I suggest an update.
WordPress has become easier I guess so I solved the problem in just one line I hope I'm not wrong.
<p class="post-info"><?php the_time('F jS, Y ');?> | by <a><?php the_author_posts_link(); ?></a> | Posted in <?php the_category(', ','' ); ?></p>
<?php the_content();?>
I hope it will be useful for people like me the are just at the beginning.
thanks again for your work.

James Summers · August 15, 2017 at 8:13 pm

Here in 2017. Great stuff man!

Andrew Sweetman · August 20, 2017 at 12:51 pm

I've found that the comma isn't being trimmed. It seems that the $seperator =", " is adding something to the end of it – pssibly nbsp. Changing trim($output, $seperator) to trim($output, ', ') removes it even though $seperator = ", ";

_wsad · August 31, 2017 at 11:18 pm

7:07 just use the implode function

chika bizman · September 4, 2017 at 6:12 am

hi Brad please help!!!! i am having troubles with the margin-bottom: 0; mine still has a significant amount of space in between….

nishant karki · October 3, 2017 at 7:18 am

Great tutorial ! But when i open the codes in firefox(at the end of this tutorial) it renders fine(for date,author, posted,etc with small letters and dark light color, same as in this tutorial) but when i open the same link with same code in chrome it does not not render as in firefox? Any suggestion why this is happening?

Adnan Rumman · October 14, 2017 at 9:12 am

would u plz tell me in foreach($categories as $category) loop why echo outside of curly bracket

Tutorials · October 31, 2017 at 1:36 pm

Lol, stupid WordPress. What was wrong with standard notation mmm/dd/yyyy…

Matt Wong · December 1, 2017 at 12:21 am

7 dislikes only because 7 people missed the like button

Elia Krisetya · December 5, 2017 at 12:30 am

Anyone know why my styles aren't working for post-info?

Miles Rose · February 11, 2018 at 2:51 am

Great tutorial, as per usual! I think I'm really starting to get a grip on wordpress theme development thanks to you.

Ray Nicol · February 16, 2018 at 4:57 pm

Great series, easy to follow and understand and very well presented – very professional.
I was finding WP theme coding tough going until I came across this series. Keep up the good work.

ahuff20 · March 20, 2018 at 7:15 pm

Can anyone give me some guidance on why my Post Styles aren't affecting my page?
My code looks like this right now:

/* Post Styles */
.post h2 {
margin-bottom: 0;
}

p.post-info {
font-size: 87%;
color: #999;
}

p.post-info a:link,
p.post-info a:visited {
color: #999;
}

Any suggestions would be greatly appreciated!

Nikola Jašić · March 29, 2018 at 5:23 am

This is all code that you need for this chapter.
<p class="post-info"><?php the_time('F j, Y g:i a'); ?> | by <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php echo esc_attr( get_the_author() ); ?>"><?php the_author(); ?></a>Posted in <?php the_category(', ','' ); ?></p>
https://developer.wordpress.org/reference/functions/get_author_posts_url/#source

maroc boutalb · May 1, 2018 at 7:29 pm

Why their is a "." before = in : $output. =

mahendra choudhary · May 19, 2018 at 3:23 pm

awesome tutorial brad ..i am loving it .good luck

Vibhav Kumar · June 14, 2018 at 10:12 am

how I can add author image as meta data on category blog view.

IsaacA192 · June 25, 2018 at 2:55 am

One thing I really am struggling to understand is what the hell is cat_name? Is it a function? It's the same with term_id… what the hell is it? I can't find anything online as to what it is or where to use it, it's driving me nuts… these things are so illusive they're only referenced in stack overflow queries but never explained what they are, sure it gets the category name but is there an API filled with a list of these things? I have no real point of reference as to how to use them or if there are MORE terms like these that need to be used elsewhere.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

en_USEnglish
en_USEnglish
%d bloggers like this: