Nice — I’ll give you a complete, minimal WordPress theme scaffold with production-ready starter code. Paste these files into a folder (for example my-starter-theme
) inside wp-content/themes/
, then activate the theme in WordPress. I include comments and small security/cleanliness touches (escaping, enqueuing, theme support).
1) style.css
(theme header — required)
/* Theme Name: My Starter Theme Theme URI: https://example.com/my-starter-theme Author: Your Name Author URI: https://example.com Description: Minimal starter theme for WordPress. Version: 1.0 License: GNU General Public License v2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Text Domain: my-starter-theme Tags: custom-background, custom-logo, custom-menu, featured-images, translation-ready */ :root{ --content-width: 1000px; --gap: 20px; --font-stack: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial; } *{box-sizing:border-box} body{ font-family:var(--font-stack); margin:0; line-height:1.6; color:#222; background:#fff; } .wrapper{ max-width:var(--content-width); margin:0 auto; padding:var(--gap); } .site-header, .site-footer{ background:#f8f8f8; padding:16px; } .site-title { margin:0; font-size:1.6rem; } .main { display:flex; gap:var(--gap); margin-top:16px; } .content { flex:1; } .sidebar { width:300px; } .entry-title { font-size:1.4rem; margin:0 0 8px; } .entry-meta { font-size:0.9rem; color:#666; margin-bottom:12px; } .post-excerpt { margin:0 0 18px; } a { color:#0073aa; text-decoration:none; } a:hover { text-decoration:underline; }
2) functions.php
<?php if (!defined('ABSPATH')) exit; // Theme setup function mst_setup_theme() { load_theme_textdomain('my-starter-theme', get_template_directory() . '/languages'); add_theme_support('title-tag'); add_theme_support('post-thumbnails'); add_theme_support('custom-logo'); add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption')); register_nav_menus(array( 'primary' => __('Primary Menu', 'my-starter-theme'), )); add_theme_support('responsive-embeds'); } add_action('after_setup_theme', 'mst_setup_theme'); // Enqueue styles & scripts function mst_enqueue_assets() { wp_enqueue_style('mst-style', get_stylesheet_uri(), array(), wp_get_theme()->get('Version')); wp_enqueue_script('mst-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array('jquery'), '1.0', true); } add_action('wp_enqueue_scripts', 'mst_enqueue_assets'); // Register widget area function mst_widgets_init() { register_sidebar(array( 'name' => __('Sidebar', 'my-starter-theme'), 'id' => 'sidebar-1', 'description' => __('Main blog sidebar', 'my-starter-theme'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', )); } add_action('widgets_init', 'mst_widgets_init'); // Clean up excerpt function mst_excerpt_more($more) { return ' …'; } add_filter('excerpt_more', 'mst_excerpt_more');
3) index.php
<?php get_header(); ?> <div class="wrapper"> <main class="main"> <div class="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <div class="entry-meta"> <span><?php echo esc_html(get_the_date()); ?></span> <?php if (get_the_author_meta('display_name')) : ?> <span> • <?php the_author(); ?></span> <?php endif; ?> </div> <div class="post-excerpt"> <?php the_excerpt(); ?> </div> </article> <?php endwhile; else: ?> <p><?php esc_html_e('No posts found.', 'my-starter-theme'); ?></p> <?php endif; ?> <div class="pagination"> <?php the_posts_pagination(array( 'mid_size' => 1, 'prev_text' => __('‹ Prev', 'my-starter-theme'), 'next_text' => __('Next ›', 'my-starter-theme'), )); ?> </div> </div> <?php get_sidebar(); ?> </main> </div> <?php get_footer(); ?>
4) header.php
<!doctype html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo('charset'); ?>"> <meta name="viewport" content="width=device-width,initial-scale=1"> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <header class="site-header"> <div class="wrapper"> <?php if (has_custom_logo()) { the_custom_logo(); } else { ?> <h1 class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>"><?php bloginfo('name'); ?></a></h1> <p><?php bloginfo('description'); ?></p> <?php } ?> <nav class="site-navigation" role="navigation" aria-label="<?php esc_attr_e('Primary Menu', 'my-starter-theme'); ?>"> <?php wp_nav_menu(array( 'theme_location' => 'primary', 'container' => false, 'menu_class' => 'menu', 'fallback_cb' => false )); ?> </nav> </div> </header>
5) footer.php
<footer class="site-footer"> <div class="wrapper"> <p>© <?php echo date_i18n( 'Y' ); ?> <?php bloginfo('name'); ?>. <?php esc_html_e('All rights reserved.', 'my-starter-theme'); ?></p> </div> </footer> <?php wp_footer(); ?> </body> </html>
6) sidebar.php
<aside class="sidebar" role="complementary"> <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?> <?php dynamic_sidebar( 'sidebar-1' ); ?> <?php else : ?> <div class="widget"> <h3 class="widget-title"><?php esc_html_e('Search', 'my-starter-theme'); ?></h3> <?php get_search_form(); ?> </div> <?php endif; ?> </aside>
7) single.php
<?php get_header(); ?> <div class="wrapper"> <main class="main"> <div class="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h1 class="entry-title"><?php the_title(); ?></h1> <div class="entry-meta"><?php echo esc_html(get_the_date()); ?> <?php esc_html_e('by', 'my-starter-theme'); ?> <?php the_author(); ?></div> <div class="entry-content"> <?php the_content(); ?> <?php wp_link_pages(array( 'before' => '<div class="page-links">' . esc_html__('Pages:', 'my-starter-theme'), 'after' => '</div>', )); ?> </div> <?php comments_template(); ?> </article> <?php endwhile; endif; ?> </div> <?php get_sidebar(); ?> </main> </div> <?php get_footer(); ?>
8) page.php
<?php get_header(); ?> <div class="wrapper"> <main class="main"> <div class="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h1 class="entry-title"><?php the_title(); ?></h1> <div class="entry-content"><?php the_content(); ?></div> </article> <?php endwhile; endif; ?> </div> <?php get_sidebar(); ?> </main> </div> <?php get_footer(); ?>
9) 404.php
<?php get_header(); ?> <div class="wrapper"> <h1><?php esc_html_e('404 — Page not found', 'my-starter-theme'); ?></h1> <p><?php esc_html_e('Sorry, we could not find that page. Try the search or go back to the home page.', 'my-starter-theme'); ?></p> <?php get_search_form(); ?> </div> <?php get_footer(); ?>
10) assets/js/navigation.js
(small example)
(function($){ $(document).ready(function(){ // simple mobile menu toggle if you add a button later $('.menu-toggle').on('click', function(){ $('.menu').toggleClass('is-open'); }); }); })(jQuery);
Extra tips and how to install
- Create a folder
my-starter-theme
underwp-content/themes/
. Put the files above inside it following their filenames and structure. - Optional: add a
screenshot.png
(1200×900) to show in the WP admin. - Activate the theme in Appearance → Themes.
- Go to Appearance → Menus and assign a menu to the Primary location.
- Add widgets in Appearance → Widgets to the Sidebar area.
- For production: sanitize and escape output as shown. Use nonces for forms, and follow WP coding standards if you expand the theme.
If you want, I can: • Expand this to a block-compatible theme (theme.json + block templates).
• Add starter templates for archive.php
and search.php
.
• Make it a child theme of a specific parent.
Tell me about use this code after any problem I will try solve any type of issue
Please like and subscribe