Archived topic
Add date on navigation bar
5 replies · Started by Michael B. on June 14, 2016
Is there a way to add the current date such as "June 13, 2016" on the navigation bar to the far right? Or at least some where at the top of the website? Thanks Michael
Hi there,
Good question!
Give this code a try:
add_action( 'generate_inside_navigation','generate_date_navigation' );
function generate_date_navigation()
{
?>
<span class="nav-date">
<?php the_date(); ?>
</span>
<?php
}
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
Then add this CSS:
.nav-date {
float: right;
}
Adding CSS: https://generatepress.com/knowledgebase/adding-css/
That should get you going :)
Hi Tom,
What would the code be if I want to add it to the secondary Nav Menu?
Regards,
Mosche
This would be the function for the secondary navigation:
add_action( 'generate_inside_secondary_navigation','generate_date_secondary_navigation' );
function generate_date_secondary_navigation()
{
?>
<span class="nav-date">
<?php the_date(); ?>
</span>
<?php
}
Thanks Much Tom.
Works like a charm.
Regards,
Mosche
Glad I could help :)
