Skip Navigation

PHP notice when Post Date shortcode is used inside a time HTML tag

Resolved

Reported for: Toolset Views 2.4

Resolved in: Toolset Views 2.4.1

Topic Tags: Views plugin

Symptoms

There is a PHP notice being logged when the Post Date shortcode is used inside a time HTML tag and the shortcode’s attributes are wrapped with single quotes. For example something like this

The following markup presents an example where the issue would appear:

<time class="post-date" datetime="[wpv-post-date format='Y-m-d']">
     [wpv-post-date]
</time>

In this specific case, we have the following PHP notice logged on the site or its debug.log file:

PHP Notice: Undefined time: input in */wp-includes/kses.php on line 866

Workaround

The solution for this issue is very simple, it is necessary just to use double quotes for wpv-post-date attributes.

Following the example presented above, we would use the double quotes for specifying the format attribute of the wpv-post-date shortcode.

<time class="post-date" datetime="[wpv-post-date format="Y-m-d"]">
     [wpv-post-date]
</time>

Additionally, another way to prevent this issue is to use any other tag instead of <time>, for example <span>:

<span class="post-date" datetime="[wpv-post-date format='Y-m-d']">
     [wpv-post-date]
</span>

Comments are closed