I am trying to get it so that all of my posts display the date at the beginning of the post content, such that each post begins as:
“August 28 – Lorem ipsum dolor sit amet…”
However, if the code is just:
<?php the_time('F j - '); ?><?php the_content('Read More'); ?>
Then because WordPress automatically adds p tags around the_content, it ends up displaying with a line break between the date and the rest of the content:
“August 28 –
Lorem ipsum dolor sit amet…
I want to insert the_date inside of the p tags around the_content, so there’s isn’t that line break. I have been looking around for possible solutions, but I haven’t found anything short of removing the p tags entirely, which I don’t want to do. Any suggestions?
You could use the
the_content
filter, like below (untested). The only thing is, that will add the date pretty much everywhere that your posts show up on your site, unless you add some logic to determine where it’s being called from. If that’s OK, give it a shot.