Site logo

Archived topic

Displaying Post Title On Desktop In Header And Before Content On Rest

17 replies · Started by Robert on January 25, 2022

Viewing posts 16–18 of 18

The goal is for the header element that includes the post date and title to display on BOTH desktop AND mobile. I need it to NOT display on tablet. On tablet I need the post title AND post date to display in the usual WP fashion.

If this is the case then you may have to NOT use wp_is_mobile() to revert to what previously worked but use only hide-on-tablet for the one you've placed inside the Header element.

But in consideration to SEO as Ying mentioned, you may have to set one of the 2 H1s to H2 or <span>.

And then for the elements you've hooked on Hook element ID 192, consider wrapping them in a DIV element width w/ a specific class so you only have to apply the display: none; for tablet on it to automatically hide both the title and date.

example:

<?php 
	echo '<div class="hide-on-desktop hide-on-mobile">';
	echo '<h1><center>' . get_the_title() . '</center></h1>';
	echo '<p><i><center>' . get_the_date() . '</center></i></p>';
	echo '</div>';
?>

This way, this block only displays on tablet which is inverse of the other element you've hook that had only hide-on-tablet.

Bingo! We have lift off! Boy was that a bit of a journey for me!

I'm perfectly ok with having the post title inside the header element as an h2. Only one h1 set is now showing in the underlying html for all resolutions which is good. I'm just happy someone caught that as I would have not known there were two of them showing up initially!

Thanks for the help from everyone. Good job as usual!

No problem. Let us know if you need further help. :D

This archived topic is closed to new replies.