I’m not quite sure if this is HTML/CSS related question, but I’ll try to post it here.
So, what I want to do?
I would like to change the Date format for my WP posts.
I already tried to change the Date format under WP Dashboard Settings, but that didn’t work for Posts (only for Comments).
The second thing I would like to do is to put the Total number of comments for each post right next to Date field.
I tried to modify that settings with my Theme editor, but the only thing I can do is to Hide/Show Date and Author.
Hi @Marin. You are using the theme Kotha. Do you have a child theme set up? The reason I asked is that if you make any changes to the code for this theme, they will be wiped out the next time you install an update for that theme. To do what you want to do, you really should make the changes in a child theme (https://codex.wordpress.org/Child_Themes).
It would probably be better if your question were moved to the WordPress forum. You may get a better response there.
I don’t have a child theme set up.
But, I use Custom CSS plugin which allows me to override every style from the original CSS file.
So, I’m not worried about that.
I can modify whatever I want with Custom CSS plugin.
My only problem is that I don’t know how to do that changes?
The trouble is that you don’t have the number of comments displayed with the posts at all, so it might necessitate adding or moving some PHP code, not adjusting your CSS. Do you have any option in your theme editor that pertains to number of comments?
Which file in the theme is creating that HTML?
Where can I find that?
No, I have no options in my theme editor that pertains to number of comments.
However, I installed a Comments plugin that allows me to show Number of comments right above the “Leave a Reply” section. But, you have to open a specific post (you can’t see that on Home page).
As a new user I’m not able to insert more than 2 hyperlinks here, so I can’t show you what I mean.
Then you will only be able to accomplish what you want by changing the php code in the theme (which means using a child theme). Once you have done that, we can help you with the code that you need for both the date formatting and displaying the number of comments.
If you don’t set up a child theme, you will have to change the code in the theme itself. That leaves you with three options: either lose your changes when you install an updated version of the theme, keep track of exactly what changes you made and make those same changes each time you install an updated version of the theme, or never install an updated version of the theme ( a very, very serious security risk).
You’re suggesting me smarter and safer choice.
But, I already made a backup on my laptop.
So, if something goes wrong I can always upload my theme files back on server with FTP.
My priority now is to fix those issues with date and comments.
I just downloaded the kotha theme and have been looking at it in my IDE.
There are two files that call the kotha_posted_on function content-single.php and content-post.php
You don’t have to. But believe me, you may not know it now, but you want to.
It shouldn’t be all that hard if you follow the steps described in the codex page WebMachine linked to in post # 2, give it a read.
Basically you’ll need to create a folder eg. kotha-child
Put your versions of the content-single and content-post files in it.
Write your equivalent of the kotha_posted_on function eg kotha_child_posted_on
Have you content-single and content-post files call your function instead of the original theme function that’ in the template-tags.php file.
That would be the same as not updating the theme. Any Security Bug fixes and Feature enhancements would not be applied.
and it would be enough to let me know what was going on.
But you could do something like this instead if you didn’t mind the comment being output to the HTML
<?php if ( 'post' == get_post_type() ) : ?>
<div class="entry-meta"><span>Date: </span>
<!-- display dates formatted the way I want them to be displayed -->
<?php kotha_child_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif; ?>