adding date/time to tooltip |

I don’t understand.
You mean like this :


@corrinarusso Yes that’s a form of tool tip, though styled a bit, I guess. I’m not looking for styling advice though, just want to make it work using the html title attribute.

But I wasn’t giving you styling advice.
You should be usig libraries that are available to you is all – make maintenance much easier :

To fix your loop, just put it in a variable :

if ( is_singular() ) {
$dateis=date('F j, Y');
$timeis=date('g:i a');
            echo the_title( '<h3 class="entry-title"><span title="Published on ' . $timeis . ' at ' . $timeis . '">', '</span></h3>' );

Sorry didn’t mean to imply that you were giving styling advice … everything I googled wanted to tell me how to style it and I didn’t want you to waste your time explaining all that in case that’s what you thought I was looking for, since you said you didn’t understand.

Anyway, the code you provided is a good starting point, and I was able to “fix” it to my needs.

First off, I figured out the $ lines need to go before the if statement. And in the span the first php should read $dateis. I thought putting echo before the_title might screw it up, but it did not – but neither did removing it altogether. So I guess it’s unnecessary, sometimes….
Once I got that fixed there was one other major problem: it was only showing the current date and time, and changed on every reload. Some digging – and trial and error – had me realizing that the $ lines needed to read as


Once I did that, the post date was then showing in the tool tip, as I want.

So thank you for putting me on the right track!

Source link