Skip to content

WordPress: Introduzione

WordPress è il CMS (Content Management System) più utilizzato al mondo, alimentando oltre il 40% di tutti i siti web.

Struttura di un Tema

mio-tema/
├── style.css
├── index.php
├── header.php
├── footer.php
├── sidebar.php
├── functions.php
└── single.php

Loop di WordPress

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');

Conclusione

WordPress offre una piattaforma flessibile per sviluppare siti web di qualsiasi tipo, grazie alla sua estensibilità e alla vasta community.

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