← Back to PHP Course | Chapter 15: Web Development | Lesson 4 of 12

PHP WordPress Development

What is WordPress?

WordPress is a PHP-based content management system that powers a huge share of the web, giving non-developers a way to manage content while still exposing a full PHP API for custom development.

Example: What is WordPress?

php
<?php
echo "WordPress: a PHP-based CMS with a full API for custom development";
?>

WordPress Hooks

Hooks are WordPress's extension mechanism: actions let your code run at a specific point in the request lifecycle, while filters let you intercept and modify data before WordPress uses or displays it.

Example: WordPress Hooks

php
<?php
// add_action('init', 'my_custom_function');
// add_filter('the_content', 'modify_content');
echo "Actions run code at a point in the lifecycle; filters modify data";
?>

The Loop

The Loop is the standard block of code every WordPress theme uses to fetch and display a list of posts, iterating through query results and rendering each one according to the theme's markup.

Example: The Loop

php
<?php
// while (have_posts()) { the_post(); the_title(); }
echo "The Loop iterates through queried posts and renders each one";
?>

Custom Post Types

Custom Post Types let you extend WordPress beyond blog posts and pages -- defining structures like products or reviews that get their own admin screens and can be queried just like built-in content.

Example: Custom Post Types

php
<?php
// register_post_type('product', ['public' => true]);
echo "Extends WordPress beyond posts and pages with its own admin screens";
?>

Shortcodes

Shortcodes let content editors trigger PHP functionality from inside the page editor by typing a bracketed tag like [gallery], without needing to touch a template file directly.

Example: Shortcodes

php
<?php
// add_shortcode('gallery', 'render_gallery_shortcode');
echo "Editors type [gallery] to trigger PHP functionality from the editor";
?>

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.