For RX Theme, the best advanced structure is to separate:
Frontend = visitor/public website files
Backend = WordPress admin/theme settings/customizer files
Core = required theme engine files
Assets = CSS, JS, images, fonts
Templates = page/post layout files
Inc = PHP modules and helpers
Here is a clean advanced folder structure:
rx-theme/
├── style.css
├── functions.php
├── index.php
├── screenshot.png
├── readme.txt
│
├── header.php
├── footer.php
├── sidebar.php
├── search.php
├── 404.php
├── archive.php
├── category.php
├── tag.php
├── author.php
├── single.php
├── page.php
├── comments.php
│
├── inc/
│ ├── core/
│ │ ├── theme-setup.php
│ │ ├── enqueue.php
│ │ ├── menus.php
│ │ ├── sidebars.php
│ │ ├── image-sizes.php
│ │ ├── theme-supports.php
│ │ ├── cleanup.php
│ │ ├── security.php
│ │ └── performance.php
│ │
│ ├── frontend/
│ │ ├── template-tags.php
│ │ ├── template-functions.php
│ │ ├── breadcrumbs.php
│ │ ├── pagination.php
│ │ ├── related-posts.php
│ │ ├── reading-time.php
│ │ ├── post-views.php
│ │ ├── schema.php
│ │ ├── seo-meta.php
│ │ ├── open-graph.php
│ │ └── table-of-contents.php
│ │
│ ├── backend/
│ │ ├── admin-menu.php
│ │ ├── admin-page.php
│ │ ├── theme-options.php
│ │ ├── settings-api.php
│ │ ├── customizer.php
│ │ ├── metaboxes.php
│ │ ├── dashboard-widgets.php
│ │ ├── admin-notices.php
│ │ └── import-export.php
│ │
│ ├── helpers/
│ │ ├── sanitization.php
│ │ ├── escaping.php
│ │ ├── conditionals.php
│ │ ├── media.php
│ │ ├── formatting.php
│ │ └── compatibility.php
│ │
│ ├── integrations/
│ │ ├── woocommerce.php
│ │ ├── elementor.php
│ │ ├── gutenberg.php
│ │ ├── rankmath.php
│ │ ├── yoast.php
│ │ └── contact-form-7.php
│ │
│ └── autoload.php
│
├── frontend/
│ ├── components/
│ │ ├── site-header.php
│ │ ├── site-footer.php
│ │ ├── nav-primary.php
│ │ ├── nav-mobile.php
│ │ ├── search-form.php
│ │ ├── post-card.php
│ │ ├── author-box.php
│ │ ├── related-post-card.php
│ │ ├── share-buttons.php
│ │ └── ad-slot.php
│ │
│ ├── layouts/
│ │ ├── layout-default.php
│ │ ├── layout-full-width.php
│ │ ├── layout-sidebar-right.php
│ │ ├── layout-sidebar-left.php
│ │ ├── layout-medical-article.php
│ │ └── layout-landing.php
│ │
│ └── parts/
│ ├── content.php
│ ├── content-single.php
│ ├── content-page.php
│ ├── content-search.php
│ ├── content-none.php
│ ├── entry-header.php
│ ├── entry-footer.php
│ └── entry-meta.php
│
├── backend/
│ ├── pages/
│ │ ├── rx-dashboard.php
│ │ ├── rx-general-settings.php
│ │ ├── rx-header-settings.php
│ │ ├── rx-footer-settings.php
│ │ ├── rx-seo-settings.php
│ │ ├── rx-performance-settings.php
│ │ ├── rx-social-settings.php
│ │ └── rx-import-export.php
│ │
│ ├── fields/
│ │ ├── field-text.php
│ │ ├── field-textarea.php
│ │ ├── field-checkbox.php
│ │ ├── field-radio.php
│ │ ├── field-select.php
│ │ ├── field-color.php
│ │ ├── field-image.php
│ │ └── field-repeater.php
│ │
│ └── assets/
│ ├── css/
│ │ └── admin.css
│ ├── js/
│ │ └── admin.js
│ └── images/
│ └── rx-logo.svg
│
├── template-parts/
│ ├── header/
│ │ ├── header-default.php
│ │ ├── header-transparent.php
│ │ ├── header-medical.php
│ │ └── mobile-header.php
│ │
│ ├── footer/
│ │ ├── footer-default.php
│ │ ├── footer-widgets.php
│ │ ├── footer-minimal.php
│ │ └── footer-medical.php
│ │
│ ├── post/
│ │ ├── post-card.php
│ │ ├── post-list.php
│ │ ├── post-grid.php
│ │ ├── post-meta.php
│ │ ├── post-author.php
│ │ └── post-related.php
│ │
│ ├── page/
│ │ ├── page-header.php
│ │ ├── page-content.php
│ │ └── page-builder.php
│ │
│ └── medical/
│ ├── disease-card.php
│ ├── symptom-box.php
│ ├── treatment-box.php
│ ├── diagnosis-box.php
│ ├── faq-box.php
│ └── medical-disclaimer.php
│
├── assets/
│ ├── css/
│ │ ├── frontend/
│ │ │ ├── main.css
│ │ │ ├── header.css
│ │ │ ├── footer.css
│ │ │ ├── blog.css
│ │ │ ├── single.css
│ │ │ ├── archive.css
│ │ │ ├── medical.css
│ │ │ ├── responsive.css
│ │ │ └── accessibility.css
│ │ │
│ │ ├── backend/
│ │ │ ├── admin.css
│ │ │ ├── settings.css
│ │ │ └── customizer.css
│ │ │
│ │ ├── dynamic/
│ │ │ ├── variables.css
│ │ │ ├── color-scheme.css
│ │ │ ├── typography.css
│ │ │ └── generated.css
│ │ │
│ │ └── vendor/
│ │ ├── normalize.css
│ │ └── icons.css
│ │
│ ├── js/
│ │ ├── frontend/
│ │ │ ├── main.js
│ │ │ ├── navigation.js
│ │ │ ├── mobile-menu.js
│ │ │ ├── search.js
│ │ │ ├── accessibility.js
│ │ │ ├── lazyload.js
│ │ │ ├── toc.js
│ │ │ ├── dark-mode.js
│ │ │ └── performance.js
│ │ │
│ │ ├── backend/
│ │ │ ├── admin.js
│ │ │ ├── settings.js
│ │ │ ├── media-upload.js
│ │ │ └── customizer.js
│ │ │
│ │ └── vendor/
│ │ └── vendor.js
│ │
│ ├── images/
│ │ ├── logo/
│ │ ├── icons/
│ │ ├── backgrounds/
│ │ └── placeholders/
│ │
│ ├── fonts/
│ │ ├── inter/
│ │ └── rx-icons/
│ │
│ └── static-js/
│ ├── accessibility.js
│ ├── frontend-helpers.js
│ └── performance-helpers.js
│
├── templates/
│ ├── template-full-width.php
│ ├── template-left-sidebar.php
│ ├── template-right-sidebar.php
│ ├── template-no-sidebar.php
│ ├── template-medical-article.php
│ ├── template-homepage.php
│ ├── template-landing-page.php
│ └── template-sitemap.php
│
├── blocks/
│ ├── rx-card/
│ │ ├── block.json
│ │ ├── index.js
│ │ ├── editor.css
│ │ └── style.css
│ │
│ ├── rx-faq/
│ │ ├── block.json
│ │ ├── index.js
│ │ ├── editor.css
│ │ └── style.css
│ │
│ └── rx-medical-box/
│ ├── block.json
│ ├── index.js
│ ├── editor.css
│ └── style.css
│
├── languages/
│ └── rx-theme.pot
│
└── build/
├── css/
├── js/
└── manifest.json
Best simple understanding
Use this idea:
inc/core/ = theme engine
inc/frontend/ = public website PHP functions
inc/backend/ = admin panel PHP functions
frontend/ = public visible template components
backend/ = admin visible pages/settings
assets/css/ = all CSS
assets/js/ = all JavaScript
template-parts/ = reusable WordPress template parts
templates/ = custom page templates
blocks/ = Gutenberg custom blocks
Your main functions.php should stay small
Do not put everything inside functions.php. Keep it like this:
<?php
/**
* RX Theme functions and definitions.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'RX_THEME_VERSION', '1.0.0' );
define( 'RX_THEME_DIR', get_template_directory() );
define( 'RX_THEME_URI', get_template_directory_uri() );
require_once RX_THEME_DIR . '/inc/autoload.php';
Then inside:
inc/autoload.php
you load all important files.
Example:
<?php
/**
* RX Theme autoload file.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$rx_theme_files = array(
'/inc/core/theme-setup.php',
'/inc/core/enqueue.php',
'/inc/core/menus.php',
'/inc/core/sidebars.php',
'/inc/core/image-sizes.php',
'/inc/core/theme-supports.php',
'/inc/core/cleanup.php',
'/inc/core/security.php',
'/inc/core/performance.php',
'/inc/helpers/sanitization.php',
'/inc/helpers/escaping.php',
'/inc/helpers/conditionals.php',
'/inc/helpers/media.php',
'/inc/helpers/formatting.php',
'/inc/frontend/template-tags.php',
'/inc/frontend/template-functions.php',
'/inc/frontend/breadcrumbs.php',
'/inc/frontend/pagination.php',
'/inc/frontend/related-posts.php',
'/inc/frontend/schema.php',
'/inc/frontend/seo-meta.php',
'/inc/backend/admin-menu.php',
'/inc/backend/theme-options.php',
'/inc/backend/settings-api.php',
'/inc/backend/customizer.php',
'/inc/backend/metaboxes.php',
);
foreach ( $rx_theme_files as $file ) {
$path = RX_THEME_DIR . $file;
if ( file_exists( $path ) ) {
require_once $path;
}
}