0

So this works:

the_title( '<h1 class="entry-title">', '</h1>' );

But this does not:

the_date( '<h4 class="entry-date">', '</h4>' );

I don't know enough if this is reserved for the_title() or if the twentyfifteen theme has specified this functionality in functions. I don't see it but I could be missing it. Or course, just printing the_date(); works as it's supposed to as well as pulling it out of the php block and wrapping it in html myself also works. Just thought there could be a nifty little way to do it like the_title there.

3

The Codex ( or Developer Resources ) is a fantastic tool when you're unsure about a function. Looking at the parameter list for the_date() it says:

the_date( $format, $before, $after, $echo );

So you need to pass in a format as the first parameter, then your HTML tags like you have it. An example could look like this:

the_date( 'l, F j, Y', '<h4 class="entry-date">', '</h4>' );
0

The the_date function does not work like that.

The first parameter is the date format you want to use.

To echo it out

the_date( 'F j, Y', '', '', true );

To get the result:

$result = the_date('F j, Y', '', '', false );

You might also want to see get_the_date.

  • 1
    the_date() would work like that if you used the second and third parameters appropriately instead of leaving them as empty strings. – s_ha_dum Nov 24 '15 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.