if ( ! wp_next_scheduled( 'bbioon_sync_scores' ) ) {
wp_schedule_event( time(), 'hourly', 'bbioon_sync_scores' );
}Three lines of scheduling, and they do most of the work this post is about. They register a recurring WordPress job that pulls model output into the database on a timer. That is the trick for serving predictions from a PHP stack: WordPress never loads the model, it loads cached scores. If you are building an ML portfolio project aimed at WordPress or WooCommerce work, that schedule is your deployment.
Egor Howell published a framework on Towards Data Science for choosing the project that gets you hired. The four criteria are personal, novel, relevant to the role, and live. He says he has reviewed over 100 applications and only a handful of projects stood out, usually because they were the same tutorials done again. I buy the framework. For people who build for WordPress I would change two things: what live should mean, and where the novel data comes from.
What does live mean for an ML portfolio project?
The deployment path in the source is a notebook refactored into Python files, a repo with tests, Poetry and a Makefile, a Streamlit dashboard on the community cloud, and a daily GitHub Actions run. For a data science role that is a reasonable path, because it shows Python that survives outside a notebook.
For WordPress work it shows less. The person hiring you wants to know whether you can ship software inside this stack: a plugin with an activation hook, a deactivation routine that clears scheduled events, a settings screen, capability checks, no fatals on PHP 8. A Streamlit link is a deployment. A plugin that runs on a site you own, or on a store you built, is a product, and it passes the personal test in a way a demo repo cannot, because the store is yours.
Where does the model run?
The model does not run in PHP, and it never runs in the request path. Most managed WordPress hosting will not run Python at all, and even where you can, loading a model inside a page request means every visitor waits for it. So split it: train offline, publish the model output as static JSON, and let WordPress fetch and cache it on a schedule. The daily GitHub Actions run in the source maps onto this cleanly, since the workflow can write the scores file to a branch or push it to object storage.
The WordPress half looks like this:
add_action( 'wp', 'bbioon_schedule_score_sync' );
function bbioon_schedule_score_sync(): void {
if ( ! wp_next_scheduled( 'bbioon_sync_scores' ) ) {
wp_schedule_event( time(), 'hourly', 'bbioon_sync_scores' );
}
}
add_action( 'bbioon_sync_scores', 'bbioon_run_score_sync' );
function bbioon_run_score_sync(): void {
$response = wp_remote_get( 'https://scores.example.com/scores.json', [ 'timeout' => 30 ] );
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
return; // keep last good scores, retry next run
}
$scores = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $scores ) ) {
return;
}
foreach ( $scores as $sku => $score ) {
$product_id = wc_get_product_id_by_sku( $sku );
if ( $product_id ) {
update_post_meta( $product_id, '_bbioon_score', (float) $score );
}
}
}On failure the handler returns early and keeps the last good scores, which is what you want from a scheduled sync: a bad run degrades the recommendations instead of killing the page. The front end then reads _bbioon_score like any other product field. If you expose the scores over the REST API, and for a portfolio you probably should, register the route on rest_api_init and set a real permission_callback rather than __return_true. I am not sure the same split holds for headless builds where the front end is not WordPress at all, but for plugin and theme work it has been the honest divide.
This kind of wiring, a scoring service on one side and a plugin that syncs and surfaces it on the other, is work I do regularly. If you have a store with a few years of order data and no way to use it, tell me what you have and I can tell you what is realistic.
Where does the novel data come from?
Public datasets fail the novelty test by definition, because every portfolio has them. A WooCommerce store is the opposite case: its order history is a dataset nobody else can build. Order lines with timestamps, prices, discount codes and categories, plus review text if the store collects it. That satisfies the novelty criterion for free, and it is relevant to the kind of work you would be hired for.
Read it with wc_get_orders rather than raw SQL. With High Performance Order Storage, which WooCommerce has shipped since 8.2, orders live in dedicated tables and no longer behave like posts, so direct queries against wp_posts for order data are a known breakage. Reviews are still comments, so get_comments with the approval filter works there.
One warning before anything goes public: order data is customer data. Anonymize it before it leaves the store, which means no emails, names or shipping addresses in the export or the repo, and write that step into the README. For a reviewer in this ecosystem, one documented anonymization step reads better than another notebook.
What if the store is too small?
Most are. A shop doing a handful of orders a day cannot honestly feed a purchase classifier, and pretending it can is how these projects stall. Rank instead of predict: order products by expected contribution to margin, flag the items most likely to run out this month, group reviews into themes for the support queue. Rankings and groupings survive small data; class probabilities do not, and a trained model is not yet a score a store can act on.
A small project you actually finish beats a large one you abandon.
The source makes that point from the hiring side, and his time budget fits the smaller project: a rough first version in about two months, an hour or two a day. A scoring script, a JSON file and a plugin with one admin screen fit inside that.
Two checks before you write any code. First, confirm wp_remote_get can reach your scoring host from the actual hosting account, because some hosts restrict outbound HTTP and that failure is annoying to find in production. Second, confirm WP-Cron fires when you expect, since plenty of hosts disable the loopback and run system cron instead; wp cron event list answers it in a minute, and the plugin handbook documents the difference. If the roles you want are pure data science at product companies, skip my version and build the source’s stack, because that is the one those hiring managers will recognize.