myc-getter: The WordPress Library That Turns Template Spaghetti Into Presets
A clean, PHP 8.0+ data layer for ACF and WordPress posts, with sanitization built in and hookable presets for reusable frontend shapes.
- myc-getter treats WordPress content as a preset-driven contract, not a pile of template-specific lookups.
- Its real value is not data retrieval, but centralized shaping and sanitization for frontend-ready output.
- The library removes repetitive ACF, taxonomy, and post-field boilerplate while keeping the result hookable.
- Its architecture makes WordPress templates smaller by moving repeated decisions into reusable presets.
The Real Problem: WordPress Templates Accumulate Debt
WordPress themes rarely become messy all at once. They accrete tiny decisions: one more get_field(), one more esc_url(), one more custom loop for a repeater, one more conditional for a taxonomy label. After a while, the template stops reading like a view layer and starts reading like a maintenance log.
That is the pain myc-getter is trying to remove. It takes the repetitive parts of WordPress data retrieval and moves them into a centralized layer that returns clean, frontend-ready arrays. The payoff is not only less code. It is less duplication, fewer escaping mistakes, and a much clearer boundary between content shape and presentation.
Presets as a Content Contract
A preset is the most important idea in the project. Instead of asking every template to decide what a “card” looks like, the library lets you define that shape once and reuse it everywhere. That makes the preset act like a contract between content, code, and design.
This is an opinionated answer to a familiar WordPress problem. Most theme code mixes retrieval, shaping, and escaping in the same file. myc-getter separates those concerns, then makes the return value consistent enough that templates can focus on layout instead of plumbing.
Inside the Orchestrator
At the center of the library is MycGetter.php, which behaves like a coordinator. It accepts a post ID or post object, reads the configured preset, and delegates work to specialized classes for standard post fields, taxonomies, and ACF data.
The WordPress detail that matters here is apply_filters('myc_getter_presets', ...). That hook makes the system extensible without making it chaotic. Other code can inject or adjust presets, which means the library fits into WordPress’s ecosystem instead of pretending the ecosystem does not exist.
How the Library Sanitizes Everything by Default
The safety story is straightforward, which is a compliment. MycGetterPost.php wraps URLs with esc_url() and text with wp_kses_post(), while MycGetterAcf.php applies field-type-specific escaping instead of one generic rule for everything.
// Conceptual example of the library's approach
$title = esc_html( $post->post_title );
$url = esc_url( get_permalink( $post ) );
$text = wp_kses_post( get_the_excerpt( $post ) );
$card = [
'title' => $title,
'url' => $url,
'text' => $text,
];
That matters because WordPress teams usually lose security in the seams. A field gets rendered in three places, one path escapes it correctly, another path does not, and the bug only shows up later. myc-getter tries to make the safe path the default path.
The ACF layer extends that idea to richer field types like links, dates, and repeaters. Rather than handing every template a raw field value and expecting each developer to know the right escape rule, the library normalizes the value before it reaches the view.
The ACF Bridge: Repeaters Without Boilerplate
The technical highlight is repeater handling. Instead of forcing templates to hand-roll nested loops, the library detects repeaters, iterates through subfields, and returns a nested array that already matches the shape a frontend needs.
That sounds minor until you have lived through it. Repeater logic is where WordPress templates often become fragile, because the code is repetitive, conditional, and easy to copy incorrectly. Abstracting it once is a real reduction in cognitive load.
A practical comparison of return shapes
| Need | Manual WordPress + ACF | myc-getter |
|---|---|---|
| Post title and URL | Multiple lookups and separate escaping calls | Returned as part of one preset-shaped array |
| Taxonomy display | Developer chooses format every time | Return shape can be requested as slug/name, id/name, or link |
| Repeater fields | Custom nested loops in templates | Nested arrays emitted by the data layer |
| Escaping | Easy to forget or duplicate | Applied by default in the handler layer |
| Reuse across templates | Often copy-pasted logic | Preset reused as a shared contract |
The point is not that raw WordPress is broken. The point is that raw WordPress leaves too many decisions at the template edge. myc-getter centralizes those decisions, which is exactly where they are easiest to keep consistent.
Why Hookability Is the Hidden Superpower
The library’s repeated use of filters is more than a WordPress convention. It is a recognition that content rules vary by project, post type, and editorial workflow. A good cleanup layer should be adjustable, not brittle.
That flexibility also makes the library easier to adopt in real teams. You can keep the default behavior for most fields, then override specific pieces when a project needs special handling. In other words, it gives you opinionated defaults without locking you into them.
What myc-getter Is Really Teaching
The deeper lesson is architectural. myc-getter treats frontend data as something worth modeling explicitly, not as a side effect of template rendering. That is why the preset idea matters so much. It turns scattered field retrieval into a reusable interface.
For WordPress teams, that shift changes the shape of maintenance. Templates get smaller. Content rules get clearer. Security becomes less dependent on memory and more dependent on structure. That is not glamorous, but it is the kind of improvement that compounds.





