Wordpress Documentation

advertise, Anuncio

TEMA PERSONALIZADO

Un tema mínimo necesita:

  • style.css

  • index.php

  • functions.php

📁 Estructura de carpetas

				
					/mi-tema/
│
├── style.css
├── index.php
├── functions.php
├── header.php
├── footer.php
├── single.php
├── page.php
├── screenshot.png (opcional)

				
			

🧾 style.css (obligatorio)

				
					/*
Theme Name: Mi Tema Personalizado
Theme URI: https://tusitio.com
Author: Erick Sánchez
Author URI: https://tusitio.com
Description: Tema básico para iniciar desde cero.
Version: 1.0
*/

				
			

📄 functions.php

				
					<?php
// Cargar estilos y scripts
add_action('wp_enqueue_scripts', function () {
  wp_enqueue_style('main-style', get_stylesheet_uri());
  // Ejemplo de JS: wp_enqueue_script('main-js', get_template_directory_uri() . '/main.js', [], false, true);
});

// Soporte de imagen destacada
add_theme_support('post-thumbnails');

// Soporte de menú
register_nav_menus([
  'menu-principal' => 'Menú Principal',
]);

// Soporte de título automático
add_theme_support('title-tag');

				
			

📄 index.php

				
					<?php get_header(); ?>

<main>
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <div><?php the_content(); ?></div>
  <?php endwhile; else : ?>
    <p>No se encontraron publicaciones.</p>
  <?php endif; ?>
</main>

<?php get_footer(); ?>

				
			

📄 header.php / footer.php

				
					<!-- header.php -->
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
  <meta charset="<?php bloginfo('charset'); ?>">
  <?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
  <header>
    <h1><?php bloginfo('name'); ?></h1>
  </header>

				
			
				
					<!-- footer.php -->
  <footer>
    <p>&copy; <?php echo date('Y'); ?> <?php bloginfo('name'); ?></p>
  </footer>
  <?php wp_footer(); ?>
</body>
</html>