WordPress Developer Ukraine, Kyiv
WordPress get_posts vs WP_Query vs query_posts: When to Use Each

WordPress get_posts vs WP_Query vs query_posts: When to Use Each

get_posts(), WP_Query or query_posts(): which one to use WordPress has three ways to get posts: get_posts(), new WP_Query() and query_posts(). They accept the same arguments and end up in the same SQL, but they behave differently, and one of them should practically never be used. Choosing the right one avoids broken pagination and posts that…
Modify the WordPress Main Query with pre_get_posts: 5 Common Patterns

Modify the WordPress Main Query with pre_get_posts: 5 Common Patterns

Modify the WordPress main query with pre_get_posts: 5 common patterns WordPress builds and runs the main query (the one behind the Loop on the home page, archives and search) before the template is loaded. When archive.php starts, the posts are already fetched. The pre_get_posts action fires after the query object is created but before the…
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…
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 Path and URL Constants: plugin_dir_path, get_template_directory, home_url Reference

WordPress Path and URL Constants: plugin_dir_path, get_template_director ...

Paths and URLs in WordPress: plugin_dir_path(), get_stylesheet_directory() and friends A plugin or theme needs two kinds of locations: file system paths for PHP (require, file_exists(), reading files) and URLs for the browser (stylesheets, scripts, images, links). Mixing them up, or hard-coding /wp-content/, is a typical source of bugs that appear only on another server, with…