: How not to display the date on certain WordPress pages? On most posts on my website the date is displayed. There are however some posts where I would not like to show the date. Would it
On most posts on my website the date is displayed. There are however some posts where I would not like to show the date.
Would it be better to use display:none; via css or actually remove the code for the date altogether.
Here is an example of the code I use (generated by a php function)
<span class="posted-on">Posted on <time class="entry-date published" datetime="2014-07-21T18:15:52+00:00">July 21, 2014</time><time class="updated" datetime="2014-07-21T18:17:35+00:00">July 21, 2014</time></span>
The reason I ask is that I was under the impression, even if I don't want to display the date, that the timestamp would be useful to search engines.
Currently I use display:none; when I don't want to show the date.
More posts by @Lee4591628
2 Comments
Sorted by latest first Latest Oldest Best
Hidden content is fine as long as you have a way of accessing that information...
To extend on Johns answer you can hide content from both users and search engines if the content can be viewed by a action. What this means is any content that is hidden must have a way of being viewed by both users and search engines.
Ideal CSS Method
This can be done in pure CSS without the need for JavaScript unless you need an additional feature such as show for X time then hide.
HTML CSS display:none method
A valid CSS method would be to use a display:none method with a hover over trigger like so:
<div class="time-icon">
<time class="time-data" datetime="2011-10-05T09:00Z">9am on October 5</time>
</div>
.time-data {display:none;}
.time-icon:hover .time-data{display:inline-block;}
You could even make the time viewable when they hover over the title of the page rather than a icon, for example:
.time-data{display:none;}
h1:hover .time-data{display:block;}
HTML CSS opacity method
Some people prefer to use opacity but bare in mind some older browsers may not support this feature and may just display the element, HTML and CSS would be the same apart from these elements:
.time-data{-webkit-opacity:0;-moz-opacity:0;opacity:0;-webkit-transition:all 2s ease;-moz-transition:all 2s ease;-ms-transition:all 2s ease;-o-transition:all 2s ease; transition:all 3s ease;}
.time-icon:hover .time-data{opacity:0.75;}
A example of this I made on JSFiddle.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.