If your home page displays your last WordPress posts, you may have noticed that the posts on home don”t show the metas informations : dates, categories, tags, authors.
This is the default behaviour of Customiz, but you might want to change this behaviour, for example to enable the Google author rich snippets.
Use the following code to display the metas on home.
add_filter('tc_show_post_metas' , 'display_metas_on_home'); function display_metas_on_home( $bool ) { return tc__f('__is_home') ? true : $bool; }
Where to paste this code? => in your functions.php file. I strongly recommend to create a child theme. Download a start-up child theme here.
Everything you need to know about child theme with Customizr here.
30 thoughts on “Displaying the post metas on home page”
I’ve tried to to this, install the child theme.. and added some code to functions.php, however nothing works.. whatever I paste in functions.php seems like it doesent affect. What am I doing wrong? It only works if I enable metas trough customize
Hey Alex,
a link to your site is always helpful. I’m using the snippet that Nicholas provided on a local test site.
It works well but only if the option in the theme customize option is enabled:
Screenshot
I use it to display meta tags on a custom page, but since I don’t want them on the front-page, I hide them via css only for the front page.
hope it helps
Hey Alex,
one more thing:
This is the last version of the code I’m using… since this tread has become long and overwhelming
Hi Nik,
following your suggestion on the forum (here) I’ve updated the snippet:
Now, I know that this is a built in function of the new Customizr, but the problem is that if I select a different page to display my latest posts I don’t get the meta. No link or my site right now bec I’m working on a local server.
Hi Kris,
Yes you should be able to manage these settings from Apperance > customizer in the latest version.
Do you have the latests version installed ?
Can you please verify that the Display posts metas option is checked in the customizer meta options ?
Cheers
I checked and tested on 2 different test sites.: either custmizr latest version and customizr-pro latest vertsion!
But maybe I did not make myself clear enough:
when you have the home page selected for your latest post, all is fine, all the metas are there and also the categories.
When another page is selected as blog page, the list is actually showing meta information but not categories. So this is what I was trying to say.
Is this something that you wanted to happen or is an issue that has not been observed before? Shall we move this topic on the customizr-pro forum or on the support forum on wordpress?
Thanks
Hi Georgio, thanks as usual for raising a interesting point!
Let’s have a look at the latest code for post metas in TC_post_metas::tc_post_metas_controller.
The post meta view is rendered if conditions defined in post metas controller are true. The default conditions to show the metas are the following (commented):
What can we do then ?
1) You can override the default with a filter on tc_show_post_metas returning a true value depending on the context,
2) and / or adding your custom post type to the array of eligible post types.
The second point will display metas for your custom post types in archive contexts for example.
Here's what I did for the code snippet section of this website :
Note : those filters use anonymous functions introduced in php version >= 5.3
Did this help ?
Cheers
Thanks Nicholas,
your snippet works great with CPT; I see that the metas are back again on the customizr snippet page.
What I can’t make it working is this:
Test site
I’ve set this page as a default page for Posts and as you can see it does not show categories, though it shows partially metas information.
Did you experienced anything like this before?
Thanks
Hi Girogio,
I am happy it helped.
About your last issue, that’s hard to say whitout seeing your code. This can have various causes.
Cheers
Actually I just noticed that also the categories and meta on the snippets list are gone:
Customizr snippets
Still wondering if there is a work around for the blog post page that is not the default home page
Yes, thanks for reporting this Giorgio, this was in my to do list for too long !
🙂
hello Nicolas
I set the home showing: no page or article
because I like the clean home
This poses a problem with Yoast that this setting does not allow you to enter the description of the home page to show in google search. In fact, the theme of the exhibition in a case like google content description.
imposed if the home that shows: the latest articles in Yoast you can set the description of the home.
I could use this option, but c’èun way to conceal the last post in home ???
thanks
Anna
Additional to above snippet. Display only date.
oops, wrond code above.
Thanks for sharing this Rezon 😀 !
OMG! I just totally solved it myself!
Will. Never. Touch. functions.php. Again.
Great, glad to read this. Nice website btw!
Hi!
I think I just killed my website. 🙁
I did exactly what you didn’t recommend, and tried to paste the code above in the functions.php-file (to get date/time for the posts to show on the home page). And now my whole site is now gone. I tried deleting the code to undo my mess, but it didn’t work. And now I can’t even access the admin panel.
I have spent a few days making the site look nice with your theme and now I just want to know if I have done it all in vain. Is it lost forever? Can I even restart? Because I can’t login anymore. The browser window just goes white. Are all my posts gone?
Please forgive me for being stupid! I hope you can help me!!
/Kristina
Hi Kristina,
First of all don’t worry you can’t “kill” your website so easily :).
1) first activate the debug mode on your website if not already done
2) then undo your last changes and re-upload a clean functions.php file.
You might want to read this quick guide on how to diagnosing problems with the Customizr theme.
Hope this helps, don’t panic, there’s always a solution!
Thank you for a super fast reply! I actually solved it on my own beofre I saw your answer. Using ftp I uploaded a clean functions.php-file and all is now well. 🙂
I know how to set my blog as the frontpage, but i dont want it as such. The blog shows as a menu item.
I’m afraid it’s just not possible… I hope you understand me well…
Rob
Argh… sorry sorry… posted the wrong links. This should work:
In the give URL’s robbcoers should be robcoers
Could you change that comment manually before publishing?
Hi Rob, in Customizr, you can set your blog page right from the customizer option panel under Front Page > Frontt Page displays.
Hope this will help, and enjoy the theme!
Hello Nicolas,
I’m sorry to get back to this question, but maybe the following will clarify my question.
For another site i am using the theme Fruitful. It’s a theme where i’ve set the home to show a slider and 3 featered pages. The page ‘Results’ page shows all blogposts from various categories.
When you check the Settings > Reading you see that i can select what to show as HOME and select a page that shows all the blogposts.
When i try to so the same with Customizr i dont get the same options on the settings page.
Can you have another look?
homepage
Settings > Reading
Results page with all posts
Hi Nicolas,
I saw that option, but its not what i want.
Please go here: http://www.robcoers.nl/prezi
and log in as: ##########
The frontpage is fine like this, but the menuitem BLOG should present all blogposts. Now i can only show a category, as you can see.
If anyone has an idea, a suggestion, please share.
Rob
Hi Rob,
This is something you need to handle with the menu creation admin panel.
Mre about menus in WordPress here : http://codex.wordpress.org/Appearance_Menus_Screen
Thanks,
Note : for future references, never provide public login/pwd in your comment! Those can be used by malicious person to hack your website!
Hi Nicolas,
I can’t find how to post a new question, so i’m sorry to use it as a comment.
I am using an frontpage with no blogposts. How do i make a menu item, that shows the blog, starting with the recents posts as normal.
I have tried creating a custom menu, showing a certain category, but that is not exactly how i want it.
Thanks and my compliments for the great works!
Rob
Hi Rob,
In the customizer options, open the Front Page accordion, then choose Front page displays : a static page.
Then choose a page (that you’ve already created and named blog for example) for your posts.
You can now use this page as an item in your menu.
Thanks and I hope this will help!
Hi, I beginner with WP. Where i must exactly copy this code?
Thanx
Hi Adam,
If you are new to Customizr (and WordPress), you might want to read this short guide on how to customize Customizr.
Then, you can you try to make a research in :
1) the Customizr theme documentation
2) the FAQ
3) how to make a research in the Customizr user’s forum
4) the Customizr code snippets
If you still have issues then post a new thread in the the Customizr user’s forum and we’ll do our best to help you.
Thanks and enjoy the theme!