How to display the current and parent category in WordPress
Need to show the category hierarchy in your theme? Learn how to get the current category and its parent using get_the_category() and get_category_parents().
An invoicing module written in PHP for the Spanish market writes a record with a hash that links it to the previous one for every invoice, prints a tax QR code, and in VERI*FACTU mode sends the record to the tax agency (AEAT). I am Mariusz Szatkowski, a developer in Gdynia who builds custom PHP applications remotely and in writing, with the screens designed by me or built from your design. This page is for a Seville company or software house that has to implement the hash, the QR code and the submission. It stays with the technical rules; who is in scope and what the regulation is for is covered on my Malaga page about the same regulation. Tax advice is outside what I do.

Photo: CEphoto, Uwe Aranas, CC BY-SA 3.0, Wikimedia Commons.
Several articles of the order leave the details to publication on AEAT’s electronic office, so in practice the PDFs on those pages decide how the code looks.
Article 13 of the order lists the fields, and AEAT’s hash specification (version 0.1.2 of 27 August 2024) turns them into an exact string. For an invoice record (registro de alta) the fields come in this order, matching the XML record design:
IDEmisorFacturaNumSerieFacturaFechaExpedicionFacturaTipoFacturaCuotaTotalImporteTotalHuella (the hash of the previous record)FechaHoraHusoGenRegistroA cancellation record (registro de anulación) uses five fields: IDEmisorFacturaAnulada, NumSerieFacturaAnulada, FechaExpedicionFacturaAnulada, the previous Huella and FechaHoraHusoGenRegistro. Event records have their own nine-field set.
AEAT’s rules for the string:
name=value, and pairs are joined with &123.1 and 123.10 are both valid=, with nothing after itThe only algorithm the order’s list L12 allows today is SHA-256. The output is hexadecimal, in capital letters, 64 characters long, and goes into the record’s own Huella field. The first record of a system is no exception: it gets a hash too, its PrimerRegistro field is set to S, and the previous-record block is left out.
AEAT’s document gives three worked examples with expected outputs. The function below reproduces the first two exactly when run on PHP 8.4.
<?php
function huellaAlta(array $r, string $previousHash): string
{
$fields = [
'IDEmisorFactura' => $r['nif'],
'NumSerieFactura' => $r['numSerie'],
'FechaExpedicionFactura' => $r['fecha'],
'TipoFactura' => $r['tipo'],
'CuotaTotal' => $r['cuota'],
'ImporteTotal' => $r['importe'],
'Huella' => $previousHash,
'FechaHoraHusoGenRegistro' => $r['generado'],
];
$parts = [];
foreach ($fields as $name => $value) {
$parts[] = $name . '=' . trim((string) $value);
}
return strtoupper(hash('sha256', implode('&', $parts)));
}
$first = huellaAlta([
'nif' => '89890001K', 'numSerie' => '12345678/G33', 'fecha' => '01-01-2024',
'tipo' => 'F1', 'cuota' => '12.35', 'importe' => '123.45',
'generado' => '2024-01-01T19:20:30+01:00',
], '');
// 3C464DAF61ACB827C65FDA19F352A4E3BDC2C640E9E9FC4CC058073F38F12F60
$second = huellaAlta([
'nif' => '89890001K', 'numSerie' => '12345679/G34', 'fecha' => '01-01-2024',
'tipo' => 'F1', 'cuota' => '12.35', 'importe' => '123.45',
'generado' => '2024-01-01T19:20:35+01:00',
], $first);
// F7B94CFD8924EDFF273501B01EE5153E4CE8F259766F88CF6ACB8935802A2B97The values are not URL-encoded: the slash in 12345678/G33 stays a slash in the hash input. PHP’s hash() returns lowercase hex, and AEAT wants uppercase. And the amount must be the same string that goes into the XML, so the code that formats ImporteTotal for the XML should be the one that feeds the hash.
The order adds the link between records in article 7: each record carries the issuer’s tax number, the series and number, and the issue date of the record immediately before it, plus the first 64 characters of its hash. “Immediately before” is by date of generation, so two requests that create invoices at the same time must not read the same previous record. A database transaction that locks the last record per issuer, or a single queue worker per issuer, keeps the chain linear.
AEAT’s specification says that when a hash sent by a VERI*FACTU system does not match AEAT’s own calculation, the record is marked “Aceptado con errores”. A bug in the string builder therefore does not show up as a rejected submission. It needs its own test, and AEAT’s three examples make a good fixture for a PHPUnit test.
Article 20 of the order requires a QR code on the printed invoice and on the image of a digital one. Under article 21 the code measures from 30x30 to 40x40 millimetres, follows ISO/IEC 18004 and uses error correction level M. For structured electronic invoices exchanged between systems, article 20.2 asks for the URL as a separate field instead of the image.
The content is a URL with four parameters: the issuer’s tax number, the series and number, the issue date and the total amount. AEAT’s QR document (version 0.5.0 of 10 December 2025) gives four base URLs:
| System | Environment | Path |
|---|---|---|
| Verifiable (VERI*FACTU) | test portal | https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR |
| Verifiable (VERI*FACTU) | production | https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR |
| Not verifiable | test portal | https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQRNoVerifactu |
| Not verifiable | production | https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQRNoVerifactu |
The parameters are nif, numserie, fecha (DD-MM-YYYY) and importe. Unlike the hash input, they must be URL-encoded in UTF-8. AEAT’s own example has a series number containing an ampersand, which must arrive as %26. In PHP, http_build_query() does this. Its default is RFC 1738 encoding, which turns spaces into plus signs; php.net documents PHP_QUERY_RFC3986 for percent-encoded spaces, which is the safer choice for a value that may contain a space.
<?php
$query = http_build_query([
'nif' => '89890001K',
'numserie' => '12345678&G33',
'fecha' => '01-01-2024',
'importe' => '241.4',
], '', '&', PHP_QUERY_RFC3986);
$url = 'https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?' . $query;
// ...ValidarQR?nif=89890001K&numserie=12345678%26G33&fecha=01-01-2024&importe=241.4That output matches the encoded example in AEAT’s document character for character.
The order leaves placement to AEAT, and the QR document fills it in:
For a PHP invoice template the tax QR code belongs in the header area at the top of page one. A PDF library that renders HTML templates needs the code as an image at a fixed physical size, so the template should set it in millimetres rather than pixels.
Article 16 of the order covers systems that send records. The messages are XML with the structure in section 4 of the annex. The flow control works like this:
The initial value of “t” is 60 seconds, and the annex allows up to 1,000 records per submission. An accepted response does not mean every record is valid; AEAT can still validate later, and a rejected submission comes back with an error code. If a technical problem blocks sending, the records go as soon as possible, in the order they were generated, with the affected messages flagged in a field for that purpose.
In PHP this fits a queue worker. The invoice is issued and its record stored in the same transaction; a worker sends pending records in generation order, stores AEAT’s “t” and the response, and never drops a record because a call failed. Systems that do not send records to AEAT sign them instead: article 14 requires a XAdES Enveloped signature under ETSI EN 319 132, made with a qualified certificate from a provider on the EU Trusted List.
The dates have changed several times, so here is the chain as the BOE text stands on 4 December 2026.
AEAT’s information note, updated on 25 November 2026, gives the result as a date: taxpayers must have their systems adapted before 6 October 2028. For producers and sellers of invoicing software the consolidated text keeps a separate rule: products fully adapted within nine months of the entry into force of Orden HAC/1177/2024, which entered into force on 29 October 2024. Nine months from that date fell in 2025. The same provision makes one exception: systems covered by multi-year maintenance contracts signed before that deadline follow the taxpayers’ date. A Seville software house that sells a PHP invoicing product should read its own position against this paragraph, not against the 2028 date alone.
PHP_QUERY_RFC3986, and never URL-encode the hash input.The declaración responsable under article 13 of the regulation stays with the producer of the software. More on my PHP work is on the PHP developer page.
If your Seville company builds or runs invoicing in PHP, send me the repository or a short description, the framework, the PDF or template library and your deadline through the contact page. The first estimate, in writing, comes at no cost. Questions of tax treatment stay with your adviser.
Examples of my work.
Tabris.js is a modern framework that enables the creation of native mobile apps from a single codebase using JavaScript or TypeScript. This solution allows d...
The olshtyn.com website is a modern information portal created with the residents and tourists of Olsztyn in mind. This project combines functionality with a...
Osemka.pl (also known as 8.pl) is a social network that was designed and implemented in 2006-2007 as a place for user integration in the era of early social ...
Describe your project by e-mail. I reply within 24 hours.
Describe your projectNeed to show the category hierarchy in your theme? Learn how to get the current category and its parent using get_the_category() and get_category_parents().
Need to get the URL of the first image or link in an article? Prefer DOMDocument over regex. Ready-made WordPress PHP for developers.
On 1 December 2026 Taylor Otwell shipped the Laravel Rust beta, and Laravel Go followed a day later. What the framework contains, what the 18x benchmark really measures, what happens to Laravel PHP and WordPress, and when a rewrite makes sense.
Custom WordPress engineering and architecture.
Scalable headless, ERP, and AI architecture for enterprise.
Stores, checkout flow, and sales logic.
Stability, updates, and post-launch support.
What the monthly care fee covers and what changes it.
Business process automation around WordPress and company systems.
Headless WordPress, Sanity, Strapi, and Contentful with Astro or Next.js.
Astro, MDX, edge delivery, and Core Web Vitals measured on real traffic.

How to start as a WordPress developer in 2026. Local environment, theme and plugin development, REST API and headless paths, security and Core Web Vitals. A practitioner playbook that does not waste your first month.

WordPress 7.0 with AI Client against Astro 7 with the Rust compiler and Vite 8. Speed, cost, SEO and security compared, plus the real bill for my own Astro 6 to 7 migration.

A detailed comparison table of EmDash CMS and WordPress across architecture, security, plugins, AI features, content model, hosting, and ecosystem maturity.