This guide is designed to demonstrate the basic principles of block development in WordPress using a hands-on approach.
Following the steps, you will create a custom block that displays the copyright symbol (©) and the current year, the perfect addition to any website’s footer...
This is part of the Block Editor Handbook, and demonstrates the classic development way.
In my Shaarli How to build incredible WordPress Blocks with Cursor AI Nick Diego and Ryan Welcher demonstrates how to build the same Block using AI
The complete code for this tutorial is available in the Block Development Examples repository on GitHub.
Jeg har i mine Shaarli henvisninger til:
Elegant WordPress Solution for Dynamic Copyright Date
32 Extremely Useful Tricks for the WordPress Functions File
Været optaget af hvordan man kan anvende en funktion til at indsætte dynamisk ©️ information.
Med FSE benyttes ikke længere footer.php til footer information. Men der kan stadig benyttes php-script.
Indsæt funktionen i temaets functions.php :
/* ===========
-ckn- Her laver vi dynamisk copyrigt på vores side.
Indsæt for eksempel i footer.php et kald til funktionen.
<?php echo ckn_copyright(); ?>
========*/
function ckn_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;
}
Herefter kan funktionen kaldes hvorsomhelst med :
<?php echo ckn_copyright(); ?>
For eksempel i sidefods template.
Music with download links.
You’re free to use this audio in any of your videos, including videos that you monetize.
Her er en elegant metode til at få opdateret © information.
Se eventuelt også den version af scriptet, der er brugt under #6 i denne :
https://www.wpbeginner.com/wp-tutorials/25-extremely-useful-tricks-for-the-wordpress-functions-file/