WordPress register nav menu PHP – Custom Navigation
Register a custom menu location with register_nav_menus(), then render it in your template with wp_nav_menu(). Includes fallback handling and a full production header nav.
Practical, copy-ready snippets from real WordPress, WooCommerce and frontend projects — written to drop straight into a theme, child theme or component.
Register a custom menu location with register_nav_menus(), then render it in your template with wp_nav_menu(). Includes fallback handling and a full production header nav.
Read an ACF Select field value and apply it as a BEM modifier class. Lets editors choose button style, card layout, or colour scheme from a fixed list.
Loop through hand-picked related posts stored in an ACF Relationship field. Returns WP_Post objects — render title, permalink, and thumbnail without extra queries.
Loop through an ACF Gallery field, render thumbnails with srcset, and open full-size images in a vanilla JS lightbox — no plugins, no jQuery.
Register a custom taxonomy in WordPress using register_taxonomy() — hierarchical (category-like) or flat (tag-like), with full i18n labels, REST API support, and permalink slugs.
A step-by-step PHP renderer for ACF Repeater fields — loop any list of sub-fields cleanly, with or without Flexible Content.
Build a project archive with an All link, project_cat term navigation, active archive classes, and a responsive 4 column project grid using native WordPress archive queries.
An ACF Flexible Content post-grid layout with two data sources — latest posts via WP_Query or hand-picked posts via a Relationship field — and two display modes: CSS…
A focused pre_get_posts helper for changing archive page sizes per post type without touching admin screens, secondary queries, or unrelated blog archives.