WordPress Developer Ukraine, Kyiv
Organise WordPress Theme Templates with get_template_part() and Partials

Organise WordPress Theme Templates with get_template_part() and Partials

Organise theme templates with get_template_part() When a theme grows, the same markup appears in many templates: the post card in the archive, the search results and the related posts, the hero section on several page templates. Copies are quick at first, and then a design change means editing six files. get_template_part() loads a partial template…
Register Custom WordPress Rewrite Rules with add_rewrite_rule and add_rewrite_tag

Register Custom WordPress Rewrite Rules with add_rewrite_rule and add_re ...

Custom URL structures with add_rewrite_rule() and query variables Post types, taxonomies and endpoints produce their URLs automatically. When you need a structure that none of them gives, for example /docs/installation/requirements/ where the first part is a section and the second a document, you write the rule yourself: a regular expression for the path and the…
WordPress WP_Rewrite: Custom Permalink Structures, Rewrite Rules, and Flush Rules Correctly

WordPress WP_Rewrite: Custom Permalink Structures, Rewrite Rules, and Fl ...

Rewrite rules in WordPress: custom post type slugs, endpoints and flushing WordPress turns pretty URLs into queries with a table of rewrite rules: regular expressions that map a path like /books/my-book/ to query variables like post_type=book&name=my-book. The table is generated by the WP_Rewrite class and stored in the rewrite_rules option. Custom post types, taxonomies and…
Send Custom HTML Email Templates in WordPress with wp_mail()

Send Custom HTML Email Templates in WordPress with wp_mail()

Send HTML emails from WordPress with your own template Every WordPress site sends emails: password resets, new user notifications, form submissions, order confirmations. By default wp_mail() sends them as plain text. For a branded email we need two things: HTML content type and a template that looks the same in all email clients, including Outlook.
WordPress Array Helpers: wp_list_pluck, wp_list_filter, and wp_list_sort for Object Arrays

WordPress Array Helpers: wp_list_pluck, wp_list_filter, and wp_list_sort ...

wp_list_pluck(), wp_list_filter() and wp_list_sort(): array helpers in WordPress WordPress returns lists everywhere: get_posts() gives WP_Post objects, get_terms() gives WP_Term objects, get_users() gives WP_User objects. Getting one field from all of them, keeping some of them or sorting them by a field are everyday tasks, and core has three small functions for them that work with…