32
				
					// Funktion zum Abfangen des Download-Requests und Zähler erhöhen
function handle_download_request() {
    if ( isset( $_GET['download_file'] ) ) {
        // Hole den aktuellen Zählerstand und setze Standardwert 0, falls er nicht vorhanden ist.
        $counter = (int) get_option( 'download_counter', 0 );
        $counter++;
        // Aktualisiere die Option in der Datenbank.
        update_option( 'download_counter', $counter );

        // Leite zur eigentlichen Datei weiter (Ändere diesen Pfad auf die URL deiner Datei).
        wp_redirect( home_url( '/wp-content/uploads/yourfile.zip' ) );
        exit;
    }
}
add_action( 'init', 'handle_download_request' );

// Shortcode zur Anzeige des Download-Counters
function display_download_count() {
    $counter = (int) get_option( 'download_counter', 0 );
    return 'Downloads: ' . $counter;
}
add_shortcode( 'download_counter', 'display_download_count' );