Cómo añadir la fecha de forma dinámica a tu copyright

Si en tu web tienes un copyright con fecha, podrías hacer que el año se actualizara de forma dinámica.

Para esto deberás añadir este código en el fichero functions.php

function comicpress_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results(” SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status = ‘publish’ ”); $output = ”; if($copyright_dates) { $copyright = ”© ” . $copyright_dates[0]->firstdate; if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) { $copyright .= ’-’ . $copyright_dates[0]->lastdate; } $output = $copyright; } return $output; }

Y en el php para el pie de página, footer.php pondríamos esto:

Esta función añadirá el siguiente texto:

© 2009 – 2010

volver arriba ↑