Skip to content

WordPress: Introduction

WordPress is the most widely used CMS (Content Management System) in the world, powering over 40% of all websites.

Theme Structure

my-theme/
├── style.css
├── index.php
├── header.php
├── footer.php
├── sidebar.php
├── functions.php
└── single.php

The WordPress Loop

php
<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
        <article>
            <h2><?php the_title(); ?></h2>
            <div><?php the_content(); ?></div>
        </article>
    <?php endwhile; ?>
<?php endif; ?>

Custom Post Types

php
function create_post_type() {
    register_post_type('portfolio',
        array(
            'labels' => array('name' => 'Portfolio'),
            'public' => true,
            'has_archive' => true,
            'supports' => array('title', 'editor', 'thumbnail')
        )
    );
}
add_action('init', 'create_post_type');

Conclusion

WordPress offers a flexible platform for developing websites of any kind, thanks to its extensibility and vast community.

Made with ❤️ by PeterDev
'Ho mio cuGGGino che lo sa fare' cit.