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().
A shop or bookkeeping tool in Liverpool that files VAT from software connects to HMRC through the VAT (MTD) API. The API is simple to read and strict to use. I am Mariusz Szatkowski, developing from Gdynia remotely and in writing. For a PHP backend I treat the HMRC developer documentation as the specification and I keep the tax and accounting judgement with your accountant. I am not an accountant or a lawyer.

Royal Albert Dock, Liverpool. Image: Rodhullandemu, licence CC BY-SA 4.0, via Wikimedia Commons.
The HMRC Developer Hub lists these functions for the VAT (MTD) API: retrieve VAT obligations, submit and view a VAT return, retrieve a VAT liability, retrieve a VAT payment, retrieve VAT penalties, retrieve financial details relating to a penalty, and retrieve information about a VAT customer. The VAT (MTD) end-to-end guide sets the minimum for a product: it must allow the customer to retrieve VAT obligations and to submit a VAT return for a period.
That minimum shapes the first build. A PHP module needs a screen or job that asks HMRC which periods are open, a way to compile the return figures from the ledger or the shop orders, and a submission step that the customer confirms. How the figures are calculated is an accounting question, and the module takes them from the books as your accountant defines them.
The VAT API uses user-restricted endpoints, so the business owner grants the software access through OAuth 2.0, the authorization code grant. HMRC documents these steps:
/oauth/authorize endpoint with the response type code, the client id, the scopes, a redirect URI and optionally a state value. The client secret never appears here. PKCE is supported and optional.expires_in of 14400, which is 4 hours.Two details cause bugs in practice. The refresh token is single-use, and refreshing invalidates the previous access token immediately if it has not expired. HMRC warns that concurrent API calls can create race conditions during refresh. In PHP, where requests run in parallel under PHP-FPM, that means a lock around the refresh, for example a database row lock, so two requests do not both try to use the same refresh token. And after 18 months a refresh token stops working, so the user has to authorise again. The data model needs a visible state for that, not a silent failure on the day a return is due.
Tokens and the client secret belong in encrypted storage outside the web root and outside the repository. The user can revoke access at any time through HMRC’s Manage authorised applications service, so a 401 response has to lead to a clear message, not a retry loop.
HMRC requires fraud prevention header data for the VAT (MTD) and Income Tax Self Assessment (MTD) APIs. The VAT API page puts it plainly: you are required by law to submit header data for this API. HMRC uses the data in transaction monitoring. It says it works with software providers to meet the specification, and that an application which keeps sending incorrect or missing data after discussion may be fined and blocked from HMRC APIs.
The headers depend on the connection method. HMRC lists eight: desktop application direct, desktop application via server, web application via server, mobile application direct, mobile application via server, batch process direct, other direct and other via server. A browser-based bookkeeping tool with a PHP backend is a web application via server. A scheduled script that files without a user present is a batch process, which HMRC lists as a separate connection method, so the method is decided before the code.
For a web application via server HMRC states that all 16 headers are mandatory and that you must submit data for all of them. The value of Gov-Client-Connection-Method is WEB_APP_VIA_SERVER on every request.
| Header | What HMRC describes | Where the data comes from |
|---|---|---|
| Gov-Client-Browser-JS-User-Agent | user agent string reported by JavaScript on the originating device | browser script |
| Gov-Client-Device-ID | identifier unique to the device, a UUID generated by the application and stored persistently, without expiry | application |
| Gov-Client-Multi-Factor | multi-factor status of users of your software, with type, timestamp and unique reference | application login |
| Gov-Client-Public-IP | public IPv4 or IPv6 address of the device | request seen by the server |
| Gov-Client-Public-IP-Timestamp | UTC time that IP was collected | server |
| Gov-Client-Public-Port | public TCP port the device used, not a server port | request seen by the server |
| Gov-Client-Screens | width, height, scaling factor and colour depth | browser script |
| Gov-Client-Timezone | local timezone as UTC plus or minus hours and minutes | browser script |
| Gov-Client-User-IDs | sign-in identifier and any internal identifier | application |
| Gov-Client-Window-Size | browser window width and height in pixels | browser script |
| Gov-Vendor-Forwarded | hops between TLS-terminating services, each with by and for | server infrastructure |
| Gov-Vendor-License-IDs | hashed license keys of the vendor software | application |
| Gov-Vendor-Product-Name | product name marketed to end users, percent encoded | application |
| Gov-Vendor-Public-IP | public IP of the servers the device sent requests to | server infrastructure |
| Gov-Vendor-Version | versions of your software involved in the request, percent encoded | application |
| Gov-Client-Connection-Method | the value WEB_APP_VIA_SERVER | application |
HMRC marks some headers as not collectable in defined cases: no multi-factor data when the software uses only a username and password, no public IP or port over a private network, no license IDs when there are none. The guide has a section on how to handle missing data, and each case gets a documented decision.
Half of the data exists only in the browser: user agent, screen size, window size, timezone. A script in the page collects it and sends it to the PHP backend with the user’s request, and the backend stores it with the session and passes it on in each HMRC call. The server adds what only it knows: the time the IP was collected, the vendor’s public IP, the product name and version, and the forwarding hops.
In PHP the manual describes REMOTE_ADDR as the address from which the user is viewing the page and REMOTE_PORT as the port on the user’s machine. The same manual notes that values behind a proxy or load balancer may not describe the original connection, and that HTTP_ entries are built from request headers. A backend behind a load balancer, which is normal for production, needs a deliberate decision about which hop supplies the client address. That decision also feeds Gov-Vendor-Forwarded.
A device identifier can be generated with random_bytes(), which the manual describes as returning cryptographically secure random bytes. HMRC wants a UUID that does not expire, stored persistently:
<?php
function device_id(): string
{
$b = random_bytes(16);
$b[6] = chr((ord($b[6]) & 0x0f) | 0x40);
$b[8] = chr((ord($b[8]) & 0x3f) | 0x80);
$h = bin2hex($b);
return sprintf('%s-%s-%s-%s-%s',
substr($h, 0, 8), substr($h, 8, 4), substr($h, 12, 4),
substr($h, 16, 4), substr($h, 20, 12));
}The value is generated once per device, saved in a long-lived cookie or local storage, and sent from then on. It is an identifier of a device, so the privacy notice of your product needs to mention it.
HMRC provides a sandbox at test-api.service.hmrc.gov.uk, against the production host api.service.hmrc.gov.uk. Test users come from the Create Test User API or its frontend service. The Gov-Test-Scenario header simulates scenarios, and each endpoint page lists the values it accepts. HMRC also offers a Test Fraud Prevention Headers API for checking header data during development, which is the quickest way to find a header with the wrong format before approval.
In a PHP project I keep the base URLs, client id and secret in environment configuration, and one HTTP client class that adds the bearer token and the headers to every request. Nothing else in the code calls HMRC. That gives one place to log requests, with the care that HMRC responses and header values can carry personal data.
The VAT (MTD) end-to-end guide describes the route. HMRC requires fraud prevention header information for all its APIs before approval can be granted and production credentials issued, and the terms of use must be accepted first. The guide says to contact HMRC’s software developer support team within two weeks of completing API testing, and that HMRC then needs 10 working days to give the outcome. After production access, HMRC asks for a live submission before the software can be listed as compatible.
The wording matters for marketing. Production credentials are not an endorsement, and I do not describe any software as HMRC approved. The accurate statement is that it connects to HMRC through the API and, once listed, that HMRC lists it as compatible.
I need access to the repository or the plugin code, to staging, and to the Developer Hub application. The wider offer is on the PHP developer page.
If your Liverpool business wants software to file VAT, send the details through the contact form: where the figures live, whether a person or a scheduled job submits, and the filing date you are working toward. The first written estimate is free, and it states the connection method and the header plan I would start from. Your accountant keeps the tax judgement.
Examples of my work.
Floresy is a leading manufacturer, wholesaler and retailer of artificial plants, flowers and trees with over 25 years of experience in creating the finest silk plants on the market.
The website frems.pl is a modern online platform presenting the offer of the manufacturer and distributor of medical equipment specializing in FREMS technolo...
Funderwear.pt is a WooCommerce online store that meets the needs of even the most demanding customers looking for unique gifts or wanting to treat themselves to premium, fun-designed underwear.
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.