customizer.php

I’ll build this as a full WordPress Customizer module for your rx theme, with many sections: identity, header, footer, typography, colors, layout, blog, single post, SEO/meta, performance toggles, social links, custom code, and security-safe sanitization.

Below is an advanced inc/options/customizer.php file for your rx theme. It adds many possible WordPress Customizer options with safe sanitization.

Create this file:

rx-theme/
└── inc/
    └── options/
        └── customizer.php

Then include it from functions.php:

require_once get_template_directory() . '/inc/options/customizer.php';

inc/options/customizer.php

<?php
/**
 * RX Theme Customizer
 *
 * Path: inc/options/customizer.php
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * ------------------------------------------------------------
 * Sanitization Helpers
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_sanitize_checkbox' ) ) {
	function rx_theme_sanitize_checkbox( $checked ) {
		return ( isset( $checked ) && true === (bool) $checked ) ? true : false;
	}
}

if ( ! function_exists( 'rx_theme_sanitize_select' ) ) {
	function rx_theme_sanitize_select( $input, $setting ) {
		$input   = sanitize_key( $input );
		$choices = $setting->manager->get_control( $setting->id )->choices;

		return array_key_exists( $input, $choices ) ? $input : $setting->default;
	}
}

if ( ! function_exists( 'rx_theme_sanitize_radio' ) ) {
	function rx_theme_sanitize_radio( $input, $setting ) {
		return rx_theme_sanitize_select( $input, $setting );
	}
}

if ( ! function_exists( 'rx_theme_sanitize_number_absint' ) ) {
	function rx_theme_sanitize_number_absint( $number, $setting ) {
		$number = absint( $number );
		return ( $number || 0 === $number ) ? $number : $setting->default;
	}
}

if ( ! function_exists( 'rx_theme_sanitize_float' ) ) {
	function rx_theme_sanitize_float( $number, $setting ) {
		$number = floatval( $number );
		return is_float( $number ) ? $number : $setting->default;
	}
}

if ( ! function_exists( 'rx_theme_sanitize_color' ) ) {
	function rx_theme_sanitize_color( $color ) {
		if ( '' === $color ) {
			return '';
		}

		if ( false === strpos( $color, 'rgba' ) ) {
			return sanitize_hex_color( $color );
		}

		$color = str_replace( ' ', '', $color );

		if ( preg_match( '/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(0|1|0?\.\d+)\)$/', $color, $matches ) ) {
			$r = min( 255, max( 0, absint( $matches[1] ) ) );
			$g = min( 255, max( 0, absint( $matches[2] ) ) );
			$b = min( 255, max( 0, absint( $matches[3] ) ) );
			$a = min( 1, max( 0, floatval( $matches[4] ) ) );

			return "rgba({$r},{$g},{$b},{$a})";
		}

		return '';
	}
}

if ( ! function_exists( 'rx_theme_sanitize_url' ) ) {
	function rx_theme_sanitize_url( $url ) {
		return esc_url_raw( $url );
	}
}

if ( ! function_exists( 'rx_theme_sanitize_textarea' ) ) {
	function rx_theme_sanitize_textarea( $text ) {
		return wp_kses_post( $text );
	}
}

if ( ! function_exists( 'rx_theme_sanitize_plain_textarea' ) ) {
	function rx_theme_sanitize_plain_textarea( $text ) {
		return sanitize_textarea_field( $text );
	}
}

if ( ! function_exists( 'rx_theme_sanitize_css' ) ) {
	function rx_theme_sanitize_css( $css ) {
		$css = wp_strip_all_tags( $css );
		$css = str_replace( array( '<', '>', '<?php', '?>' ), '', $css );
		return $css;
	}
}

if ( ! function_exists( 'rx_theme_sanitize_html_limited' ) ) {
	function rx_theme_sanitize_html_limited( $html ) {
		$allowed = array(
			'a'      => array(
				'href'   => true,
				'title'  => true,
				'target' => true,
				'rel'    => true,
				'class'  => true,
			),
			'br'     => array(),
			'em'     => array(),
			'strong' => array(),
			'span'   => array(
				'class' => true,
			),
			'p'      => array(
				'class' => true,
			),
		);

		return wp_kses( $html, $allowed );
	}
}

/**
 * ------------------------------------------------------------
 * Register Customizer Options
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_customize_register' ) ) {

	function rx_theme_customize_register( $wp_customize ) {

		/**
		 * Transport refresh for core options.
		 */
		$wp_customize->get_setting( 'blogname' )->transport        = 'postMessage';
		$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';

		if ( isset( $wp_customize->selective_refresh ) ) {
			$wp_customize->selective_refresh->add_partial(
				'blogname',
				array(
					'selector'        => '.site-title a',
					'render_callback' => 'rx_theme_customize_partial_blogname',
				)
			);

			$wp_customize->selective_refresh->add_partial(
				'blogdescription',
				array(
					'selector'        => '.site-description',
					'render_callback' => 'rx_theme_customize_partial_blogdescription',
				)
			);
		}

		/**
		 * ------------------------------------------------------------
		 * Panels
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_panel(
			'rx_theme_general_panel',
			array(
				'title'       => esc_html__( 'RX General Settings', 'rx-theme' ),
				'description' => esc_html__( 'Global theme settings.', 'rx-theme' ),
				'priority'    => 10,
			)
		);

		$wp_customize->add_panel(
			'rx_theme_design_panel',
			array(
				'title'       => esc_html__( 'RX Design & Style', 'rx-theme' ),
				'description' => esc_html__( 'Colors, typography, spacing, and visual design.', 'rx-theme' ),
				'priority'    => 20,
			)
		);

		$wp_customize->add_panel(
			'rx_theme_layout_panel',
			array(
				'title'       => esc_html__( 'RX Layout Builder', 'rx-theme' ),
				'description' => esc_html__( 'Header, footer, sidebar, blog, and page layout settings.', 'rx-theme' ),
				'priority'    => 30,
			)
		);

		$wp_customize->add_panel(
			'rx_theme_content_panel',
			array(
				'title'       => esc_html__( 'RX Content Settings', 'rx-theme' ),
				'description' => esc_html__( 'Blog, single post, archive, search, and page content options.', 'rx-theme' ),
				'priority'    => 40,
			)
		);

		$wp_customize->add_panel(
			'rx_theme_performance_panel',
			array(
				'title'       => esc_html__( 'RX Performance & SEO', 'rx-theme' ),
				'description' => esc_html__( 'Performance, schema, SEO, preload, lazy load, and optimization settings.', 'rx-theme' ),
				'priority'    => 50,
			)
		);

		$wp_customize->add_panel(
			'rx_theme_extra_panel',
			array(
				'title'       => esc_html__( 'RX Extra Features', 'rx-theme' ),
				'description' => esc_html__( 'Social links, notices, custom CSS, and extra theme controls.', 'rx-theme' ),
				'priority'    => 60,
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Sections
		 * ------------------------------------------------------------
		 */

		$sections = array(
			'rx_theme_site_identity_extra' => array(
				'title' => esc_html__( 'Extra Site Identity', 'rx-theme' ),
				'panel' => 'rx_theme_general_panel',
			),
			'rx_theme_global_options' => array(
				'title' => esc_html__( 'Global Options', 'rx-theme' ),
				'panel' => 'rx_theme_general_panel',
			),
			'rx_theme_header_options' => array(
				'title' => esc_html__( 'Header Options', 'rx-theme' ),
				'panel' => 'rx_theme_layout_panel',
			),
			'rx_theme_navigation_options' => array(
				'title' => esc_html__( 'Navigation Menu', 'rx-theme' ),
				'panel' => 'rx_theme_layout_panel',
			),
			'rx_theme_footer_options' => array(
				'title' => esc_html__( 'Footer Options', 'rx-theme' ),
				'panel' => 'rx_theme_layout_panel',
			),
			'rx_theme_sidebar_options' => array(
				'title' => esc_html__( 'Sidebar Options', 'rx-theme' ),
				'panel' => 'rx_theme_layout_panel',
			),
			'rx_theme_container_options' => array(
				'title' => esc_html__( 'Container & Spacing', 'rx-theme' ),
				'panel' => 'rx_theme_layout_panel',
			),
			'rx_theme_color_options' => array(
				'title' => esc_html__( 'Color Options', 'rx-theme' ),
				'panel' => 'rx_theme_design_panel',
			),
			'rx_theme_typography_options' => array(
				'title' => esc_html__( 'Typography Options', 'rx-theme' ),
				'panel' => 'rx_theme_design_panel',
			),
			'rx_theme_button_options' => array(
				'title' => esc_html__( 'Button Style', 'rx-theme' ),
				'panel' => 'rx_theme_design_panel',
			),
			'rx_theme_blog_options' => array(
				'title' => esc_html__( 'Blog / Archive Options', 'rx-theme' ),
				'panel' => 'rx_theme_content_panel',
			),
			'rx_theme_single_options' => array(
				'title' => esc_html__( 'Single Post Options', 'rx-theme' ),
				'panel' => 'rx_theme_content_panel',
			),
			'rx_theme_page_options' => array(
				'title' => esc_html__( 'Page Options', 'rx-theme' ),
				'panel' => 'rx_theme_content_panel',
			),
			'rx_theme_search_options' => array(
				'title' => esc_html__( 'Search Page Options', 'rx-theme' ),
				'panel' => 'rx_theme_content_panel',
			),
			'rx_theme_breadcrumb_options' => array(
				'title' => esc_html__( 'Breadcrumb Options', 'rx-theme' ),
				'panel' => 'rx_theme_content_panel',
			),
			'rx_theme_seo_options' => array(
				'title' => esc_html__( 'SEO Options', 'rx-theme' ),
				'panel' => 'rx_theme_performance_panel',
			),
			'rx_theme_schema_options' => array(
				'title' => esc_html__( 'Schema Options', 'rx-theme' ),
				'panel' => 'rx_theme_performance_panel',
			),
			'rx_theme_performance_options' => array(
				'title' => esc_html__( 'Performance Options', 'rx-theme' ),
				'panel' => 'rx_theme_performance_panel',
			),
			'rx_theme_social_options' => array(
				'title' => esc_html__( 'Social Links', 'rx-theme' ),
				'panel' => 'rx_theme_extra_panel',
			),
			'rx_theme_notice_options' => array(
				'title' => esc_html__( 'Top Notice Bar', 'rx-theme' ),
				'panel' => 'rx_theme_extra_panel',
			),
			'rx_theme_custom_code_options' => array(
				'title' => esc_html__( 'Custom Code', 'rx-theme' ),
				'panel' => 'rx_theme_extra_panel',
			),
		);

		foreach ( $sections as $section_id => $section ) {
			$wp_customize->add_section(
				$section_id,
				array(
					'title'    => $section['title'],
					'panel'    => $section['panel'],
					'priority' => 10,
				)
			);
		}

		/**
		 * ------------------------------------------------------------
		 * Reusable helper arrays
		 * ------------------------------------------------------------
		 */

		$layout_choices = array(
			'full-width'      => esc_html__( 'Full Width', 'rx-theme' ),
			'boxed'           => esc_html__( 'Boxed', 'rx-theme' ),
			'content-sidebar' => esc_html__( 'Content / Sidebar', 'rx-theme' ),
			'sidebar-content' => esc_html__( 'Sidebar / Content', 'rx-theme' ),
			'no-sidebar'      => esc_html__( 'No Sidebar', 'rx-theme' ),
		);

		$alignment_choices = array(
			'left'   => esc_html__( 'Left', 'rx-theme' ),
			'center' => esc_html__( 'Center', 'rx-theme' ),
			'right'  => esc_html__( 'Right', 'rx-theme' ),
		);

		/**
		 * ------------------------------------------------------------
		 * Site Identity Extra
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_logo_width',
			array(
				'default'           => 180,
				'sanitize_callback' => 'rx_theme_sanitize_number_absint',
				'transport'         => 'postMessage',
			)
		);

		$wp_customize->add_control(
			'rx_theme_logo_width',
			array(
				'label'       => esc_html__( 'Logo Width', 'rx-theme' ),
				'description' => esc_html__( 'Logo width in pixels.', 'rx-theme' ),
				'section'     => 'rx_theme_site_identity_extra',
				'type'        => 'number',
				'input_attrs' => array(
					'min'  => 40,
					'max'  => 600,
					'step' => 1,
				),
			)
		);

		$wp_customize->add_setting(
			'rx_theme_retina_logo',
			array(
				'default'           => '',
				'sanitize_callback' => 'rx_theme_sanitize_url',
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Image_Control(
				$wp_customize,
				'rx_theme_retina_logo',
				array(
					'label'       => esc_html__( 'Retina Logo', 'rx-theme' ),
					'description' => esc_html__( 'Upload a 2x size logo for retina screens.', 'rx-theme' ),
					'section'     => 'rx_theme_site_identity_extra',
				)
			)
		);

		$wp_customize->add_setting(
			'rx_theme_show_tagline',
			array(
				'default'           => true,
				'sanitize_callback' => 'rx_theme_sanitize_checkbox',
			)
		);

		$wp_customize->add_control(
			'rx_theme_show_tagline',
			array(
				'label'   => esc_html__( 'Show Site Tagline', 'rx-theme' ),
				'section' => 'rx_theme_site_identity_extra',
				'type'    => 'checkbox',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Global Options
		 * ------------------------------------------------------------
		 */

		$global_checkboxes = array(
			'rx_theme_enable_preloader'      => array( esc_html__( 'Enable Preloader', 'rx-theme' ), false ),
			'rx_theme_enable_back_to_top'    => array( esc_html__( 'Enable Back To Top Button', 'rx-theme' ), true ),
			'rx_theme_enable_smooth_scroll'  => array( esc_html__( 'Enable Smooth Scroll', 'rx-theme' ), true ),
			'rx_theme_enable_dark_mode'      => array( esc_html__( 'Enable Dark Mode Toggle', 'rx-theme' ), false ),
			'rx_theme_enable_page_animation' => array( esc_html__( 'Enable Page Animation', 'rx-theme' ), false ),
			'rx_theme_enable_sticky_widget'  => array( esc_html__( 'Enable Sticky Sidebar Widget', 'rx-theme' ), true ),
		);

		foreach ( $global_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_global_options',
					'type'    => 'checkbox',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_site_layout',
			array(
				'default'           => 'full-width',
				'sanitize_callback' => 'rx_theme_sanitize_select',
			)
		);

		$wp_customize->add_control(
			'rx_theme_site_layout',
			array(
				'label'   => esc_html__( 'Global Site Layout', 'rx-theme' ),
				'section' => 'rx_theme_global_options',
				'type'    => 'select',
				'choices' => $layout_choices,
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Header Options
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_header_layout',
			array(
				'default'           => 'layout-1',
				'sanitize_callback' => 'rx_theme_sanitize_select',
			)
		);

		$wp_customize->add_control(
			'rx_theme_header_layout',
			array(
				'label'   => esc_html__( 'Header Layout', 'rx-theme' ),
				'section' => 'rx_theme_header_options',
				'type'    => 'select',
				'choices' => array(
					'layout-1' => esc_html__( 'Logo Left / Menu Right', 'rx-theme' ),
					'layout-2' => esc_html__( 'Logo Center / Menu Bottom', 'rx-theme' ),
					'layout-3' => esc_html__( 'Menu Left / Logo Center', 'rx-theme' ),
					'layout-4' => esc_html__( 'Minimal Header', 'rx-theme' ),
				),
			)
		);

		$header_checkboxes = array(
			'rx_theme_enable_topbar'        => array( esc_html__( 'Enable Top Bar', 'rx-theme' ), false ),
			'rx_theme_enable_sticky_header' => array( esc_html__( 'Enable Sticky Header', 'rx-theme' ), true ),
			'rx_theme_enable_header_search' => array( esc_html__( 'Enable Header Search', 'rx-theme' ), true ),
			'rx_theme_enable_header_button' => array( esc_html__( 'Enable Header Button', 'rx-theme' ), false ),
			'rx_theme_enable_mobile_header' => array( esc_html__( 'Enable Mobile Header', 'rx-theme' ), true ),
		);

		foreach ( $header_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_header_options',
					'type'    => 'checkbox',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_header_button_text',
			array(
				'default'           => esc_html__( 'Contact Us', 'rx-theme' ),
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			'rx_theme_header_button_text',
			array(
				'label'   => esc_html__( 'Header Button Text', 'rx-theme' ),
				'section' => 'rx_theme_header_options',
				'type'    => 'text',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_header_button_url',
			array(
				'default'           => '#',
				'sanitize_callback' => 'rx_theme_sanitize_url',
			)
		);

		$wp_customize->add_control(
			'rx_theme_header_button_url',
			array(
				'label'   => esc_html__( 'Header Button URL', 'rx-theme' ),
				'section' => 'rx_theme_header_options',
				'type'    => 'url',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_topbar_text',
			array(
				'default'           => esc_html__( 'Welcome to RX Theme', 'rx-theme' ),
				'sanitize_callback' => 'rx_theme_sanitize_html_limited',
			)
		);

		$wp_customize->add_control(
			'rx_theme_topbar_text',
			array(
				'label'   => esc_html__( 'Top Bar Text', 'rx-theme' ),
				'section' => 'rx_theme_header_options',
				'type'    => 'textarea',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Navigation Options
		 * ------------------------------------------------------------
		 */

		$nav_checkboxes = array(
			'rx_theme_enable_dropdown_animation' => array( esc_html__( 'Enable Dropdown Animation', 'rx-theme' ), true ),
			'rx_theme_enable_mobile_menu_close' => array( esc_html__( 'Show Mobile Menu Close Button', 'rx-theme' ), true ),
			'rx_theme_enable_menu_description'  => array( esc_html__( 'Show Menu Description', 'rx-theme' ), false ),
		);

		foreach ( $nav_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_navigation_options',
					'type'    => 'checkbox',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_menu_alignment',
			array(
				'default'           => 'right',
				'sanitize_callback' => 'rx_theme_sanitize_select',
			)
		);

		$wp_customize->add_control(
			'rx_theme_menu_alignment',
			array(
				'label'   => esc_html__( 'Menu Alignment', 'rx-theme' ),
				'section' => 'rx_theme_navigation_options',
				'type'    => 'select',
				'choices' => $alignment_choices,
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Footer Options
		 * ------------------------------------------------------------
		 */

		$footer_checkboxes = array(
			'rx_theme_enable_footer_widgets' => array( esc_html__( 'Enable Footer Widgets', 'rx-theme' ), true ),
			'rx_theme_enable_footer_menu'    => array( esc_html__( 'Enable Footer Menu', 'rx-theme' ), true ),
			'rx_theme_enable_footer_social'  => array( esc_html__( 'Enable Footer Social Icons', 'rx-theme' ), true ),
			'rx_theme_enable_copyright'      => array( esc_html__( 'Enable Copyright Text', 'rx-theme' ), true ),
		);

		foreach ( $footer_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_footer_options',
					'type'    => 'checkbox',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_footer_columns',
			array(
				'default'           => 4,
				'sanitize_callback' => 'rx_theme_sanitize_number_absint',
			)
		);

		$wp_customize->add_control(
			'rx_theme_footer_columns',
			array(
				'label'       => esc_html__( 'Footer Widget Columns', 'rx-theme' ),
				'section'     => 'rx_theme_footer_options',
				'type'        => 'number',
				'input_attrs' => array(
					'min' => 1,
					'max' => 6,
				),
			)
		);

		$wp_customize->add_setting(
			'rx_theme_footer_copyright',
			array(
				'default'           => sprintf(
					esc_html__( 'Copyright © %s RX Theme. All rights reserved.', 'rx-theme' ),
					date_i18n( 'Y' )
				),
				'sanitize_callback' => 'rx_theme_sanitize_html_limited',
			)
		);

		$wp_customize->add_control(
			'rx_theme_footer_copyright',
			array(
				'label'   => esc_html__( 'Copyright Text', 'rx-theme' ),
				'section' => 'rx_theme_footer_options',
				'type'    => 'textarea',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Sidebar Options
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_sidebar_layout',
			array(
				'default'           => 'content-sidebar',
				'sanitize_callback' => 'rx_theme_sanitize_select',
			)
		);

		$wp_customize->add_control(
			'rx_theme_sidebar_layout',
			array(
				'label'   => esc_html__( 'Default Sidebar Layout', 'rx-theme' ),
				'section' => 'rx_theme_sidebar_options',
				'type'    => 'select',
				'choices' => array(
					'content-sidebar' => esc_html__( 'Content / Sidebar', 'rx-theme' ),
					'sidebar-content' => esc_html__( 'Sidebar / Content', 'rx-theme' ),
					'no-sidebar'      => esc_html__( 'No Sidebar', 'rx-theme' ),
				),
			)
		);

		$wp_customize->add_setting(
			'rx_theme_sidebar_width',
			array(
				'default'           => 30,
				'sanitize_callback' => 'rx_theme_sanitize_number_absint',
			)
		);

		$wp_customize->add_control(
			'rx_theme_sidebar_width',
			array(
				'label'       => esc_html__( 'Sidebar Width (%)', 'rx-theme' ),
				'section'     => 'rx_theme_sidebar_options',
				'type'        => 'number',
				'input_attrs' => array(
					'min' => 20,
					'max' => 45,
				),
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Container & Spacing
		 * ------------------------------------------------------------
		 */

		$spacing_numbers = array(
			'rx_theme_container_width' => array(
				'label'   => esc_html__( 'Container Width PX', 'rx-theme' ),
				'default' => 1200,
				'min'     => 960,
				'max'     => 1920,
			),
			'rx_theme_content_padding_top' => array(
				'label'   => esc_html__( 'Content Padding Top PX', 'rx-theme' ),
				'default' => 40,
				'min'     => 0,
				'max'     => 200,
			),
			'rx_theme_content_padding_bottom' => array(
				'label'   => esc_html__( 'Content Padding Bottom PX', 'rx-theme' ),
				'default' => 40,
				'min'     => 0,
				'max'     => 200,
			),
			'rx_theme_card_border_radius' => array(
				'label'   => esc_html__( 'Card Border Radius PX', 'rx-theme' ),
				'default' => 12,
				'min'     => 0,
				'max'     => 80,
			),
		);

		foreach ( $spacing_numbers as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data['default'],
					'sanitize_callback' => 'rx_theme_sanitize_number_absint',
					'transport'         => 'postMessage',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'       => $data['label'],
					'section'     => 'rx_theme_container_options',
					'type'        => 'number',
					'input_attrs' => array(
						'min' => $data['min'],
						'max' => $data['max'],
					),
				)
			);
		}

		/**
		 * ------------------------------------------------------------
		 * Color Options
		 * ------------------------------------------------------------
		 */

		$color_options = array(
			'rx_theme_primary_color' => array(
				'label'   => esc_html__( 'Primary Color', 'rx-theme' ),
				'default' => '#2563eb',
			),
			'rx_theme_secondary_color' => array(
				'label'   => esc_html__( 'Secondary Color', 'rx-theme' ),
				'default' => '#0f172a',
			),
			'rx_theme_accent_color' => array(
				'label'   => esc_html__( 'Accent Color', 'rx-theme' ),
				'default' => '#16a34a',
			),
			'rx_theme_body_bg_color' => array(
				'label'   => esc_html__( 'Body Background Color', 'rx-theme' ),
				'default' => '#ffffff',
			),
			'rx_theme_body_text_color' => array(
				'label'   => esc_html__( 'Body Text Color', 'rx-theme' ),
				'default' => '#1f2937',
			),
			'rx_theme_heading_color' => array(
				'label'   => esc_html__( 'Heading Color', 'rx-theme' ),
				'default' => '#111827',
			),
			'rx_theme_link_color' => array(
				'label'   => esc_html__( 'Link Color', 'rx-theme' ),
				'default' => '#2563eb',
			),
			'rx_theme_link_hover_color' => array(
				'label'   => esc_html__( 'Link Hover Color', 'rx-theme' ),
				'default' => '#1d4ed8',
			),
			'rx_theme_header_bg_color' => array(
				'label'   => esc_html__( 'Header Background Color', 'rx-theme' ),
				'default' => '#ffffff',
			),
			'rx_theme_footer_bg_color' => array(
				'label'   => esc_html__( 'Footer Background Color', 'rx-theme' ),
				'default' => '#020617',
			),
			'rx_theme_footer_text_color' => array(
				'label'   => esc_html__( 'Footer Text Color', 'rx-theme' ),
				'default' => '#e5e7eb',
			),
		);

		foreach ( $color_options as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data['default'],
					'sanitize_callback' => 'rx_theme_sanitize_color',
					'transport'         => 'postMessage',
				)
			);

			$wp_customize->add_control(
				new WP_Customize_Color_Control(
					$wp_customize,
					$id,
					array(
						'label'   => $data['label'],
						'section' => 'rx_theme_color_options',
					)
				)
			);
		}

		/**
		 * ------------------------------------------------------------
		 * Typography Options
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_body_font_family',
			array(
				'default'           => 'system',
				'sanitize_callback' => 'rx_theme_sanitize_select',
			)
		);

		$wp_customize->add_control(
			'rx_theme_body_font_family',
			array(
				'label'   => esc_html__( 'Body Font Family', 'rx-theme' ),
				'section' => 'rx_theme_typography_options',
				'type'    => 'select',
				'choices' => array(
					'system'      => esc_html__( 'System Font', 'rx-theme' ),
					'inter'       => esc_html__( 'Inter', 'rx-theme' ),
					'roboto'      => esc_html__( 'Roboto', 'rx-theme' ),
					'poppins'     => esc_html__( 'Poppins', 'rx-theme' ),
					'lato'        => esc_html__( 'Lato', 'rx-theme' ),
					'merriweather'=> esc_html__( 'Merriweather', 'rx-theme' ),
				),
			)
		);

		$wp_customize->add_setting(
			'rx_theme_heading_font_family',
			array(
				'default'           => 'system',
				'sanitize_callback' => 'rx_theme_sanitize_select',
			)
		);

		$wp_customize->add_control(
			'rx_theme_heading_font_family',
			array(
				'label'   => esc_html__( 'Heading Font Family', 'rx-theme' ),
				'section' => 'rx_theme_typography_options',
				'type'    => 'select',
				'choices' => array(
					'system'       => esc_html__( 'System Font', 'rx-theme' ),
					'inter'        => esc_html__( 'Inter', 'rx-theme' ),
					'roboto'       => esc_html__( 'Roboto', 'rx-theme' ),
					'poppins'      => esc_html__( 'Poppins', 'rx-theme' ),
					'merriweather' => esc_html__( 'Merriweather', 'rx-theme' ),
					'playfair'     => esc_html__( 'Playfair Display', 'rx-theme' ),
				),
			)
		);

		$typography_numbers = array(
			'rx_theme_body_font_size' => array(
				'label'   => esc_html__( 'Body Font Size PX', 'rx-theme' ),
				'default' => 16,
				'min'     => 12,
				'max'     => 24,
			),
			'rx_theme_body_line_height' => array(
				'label'   => esc_html__( 'Body Line Height', 'rx-theme' ),
				'default' => 1.7,
				'min'     => 1,
				'max'     => 3,
				'step'    => 0.1,
				'float'   => true,
			),
			'rx_theme_h1_font_size' => array(
				'label'   => esc_html__( 'H1 Font Size PX', 'rx-theme' ),
				'default' => 42,
				'min'     => 24,
				'max'     => 80,
			),
			'rx_theme_h2_font_size' => array(
				'label'   => esc_html__( 'H2 Font Size PX', 'rx-theme' ),
				'default' => 34,
				'min'     => 20,
				'max'     => 70,
			),
			'rx_theme_h3_font_size' => array(
				'label'   => esc_html__( 'H3 Font Size PX', 'rx-theme' ),
				'default' => 28,
				'min'     => 18,
				'max'     => 60,
			),
		);

		foreach ( $typography_numbers as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data['default'],
					'sanitize_callback' => ! empty( $data['float'] ) ? 'rx_theme_sanitize_float' : 'rx_theme_sanitize_number_absint',
					'transport'         => 'postMessage',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'       => $data['label'],
					'section'     => 'rx_theme_typography_options',
					'type'        => 'number',
					'input_attrs' => array(
						'min'  => $data['min'],
						'max'  => $data['max'],
						'step' => isset( $data['step'] ) ? $data['step'] : 1,
					),
				)
			);
		}

		/**
		 * ------------------------------------------------------------
		 * Button Style
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_button_style',
			array(
				'default'           => 'rounded',
				'sanitize_callback' => 'rx_theme_sanitize_select',
			)
		);

		$wp_customize->add_control(
			'rx_theme_button_style',
			array(
				'label'   => esc_html__( 'Button Style', 'rx-theme' ),
				'section' => 'rx_theme_button_options',
				'type'    => 'select',
				'choices' => array(
					'square'  => esc_html__( 'Square', 'rx-theme' ),
					'rounded' => esc_html__( 'Rounded', 'rx-theme' ),
					'pill'    => esc_html__( 'Pill', 'rx-theme' ),
				),
			)
		);

		$wp_customize->add_setting(
			'rx_theme_button_radius',
			array(
				'default'           => 8,
				'sanitize_callback' => 'rx_theme_sanitize_number_absint',
			)
		);

		$wp_customize->add_control(
			'rx_theme_button_radius',
			array(
				'label'       => esc_html__( 'Button Border Radius PX', 'rx-theme' ),
				'section'     => 'rx_theme_button_options',
				'type'        => 'number',
				'input_attrs' => array(
					'min' => 0,
					'max' => 60,
				),
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Blog / Archive Options
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_blog_layout',
			array(
				'default'           => 'grid',
				'sanitize_callback' => 'rx_theme_sanitize_select',
			)
		);

		$wp_customize->add_control(
			'rx_theme_blog_layout',
			array(
				'label'   => esc_html__( 'Blog Layout', 'rx-theme' ),
				'section' => 'rx_theme_blog_options',
				'type'    => 'select',
				'choices' => array(
					'list'     => esc_html__( 'List', 'rx-theme' ),
					'grid'     => esc_html__( 'Grid', 'rx-theme' ),
					'masonry'  => esc_html__( 'Masonry', 'rx-theme' ),
					'classic'  => esc_html__( 'Classic', 'rx-theme' ),
				),
			)
		);

		$wp_customize->add_setting(
			'rx_theme_blog_columns',
			array(
				'default'           => 3,
				'sanitize_callback' => 'rx_theme_sanitize_number_absint',
			)
		);

		$wp_customize->add_control(
			'rx_theme_blog_columns',
			array(
				'label'       => esc_html__( 'Blog Grid Columns', 'rx-theme' ),
				'section'     => 'rx_theme_blog_options',
				'type'        => 'number',
				'input_attrs' => array(
					'min' => 1,
					'max' => 4,
				),
			)
		);

		$blog_checkboxes = array(
			'rx_theme_blog_show_featured_image' => array( esc_html__( 'Show Featured Image', 'rx-theme' ), true ),
			'rx_theme_blog_show_category'       => array( esc_html__( 'Show Category', 'rx-theme' ), true ),
			'rx_theme_blog_show_author'         => array( esc_html__( 'Show Author', 'rx-theme' ), true ),
			'rx_theme_blog_show_date'           => array( esc_html__( 'Show Date', 'rx-theme' ), true ),
			'rx_theme_blog_show_comments'       => array( esc_html__( 'Show Comments Count', 'rx-theme' ), true ),
			'rx_theme_blog_show_excerpt'        => array( esc_html__( 'Show Excerpt', 'rx-theme' ), true ),
			'rx_theme_blog_show_read_more'      => array( esc_html__( 'Show Read More Button', 'rx-theme' ), true ),
		);

		foreach ( $blog_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_blog_options',
					'type'    => 'checkbox',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_excerpt_length',
			array(
				'default'           => 30,
				'sanitize_callback' => 'rx_theme_sanitize_number_absint',
			)
		);

		$wp_customize->add_control(
			'rx_theme_excerpt_length',
			array(
				'label'       => esc_html__( 'Excerpt Length', 'rx-theme' ),
				'section'     => 'rx_theme_blog_options',
				'type'        => 'number',
				'input_attrs' => array(
					'min' => 5,
					'max' => 100,
				),
			)
		);

		$wp_customize->add_setting(
			'rx_theme_read_more_text',
			array(
				'default'           => esc_html__( 'Read More', 'rx-theme' ),
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			'rx_theme_read_more_text',
			array(
				'label'   => esc_html__( 'Read More Text', 'rx-theme' ),
				'section' => 'rx_theme_blog_options',
				'type'    => 'text',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Single Post Options
		 * ------------------------------------------------------------
		 */

		$single_checkboxes = array(
			'rx_theme_single_show_featured_image' => array( esc_html__( 'Show Featured Image', 'rx-theme' ), true ),
			'rx_theme_single_show_category'       => array( esc_html__( 'Show Category', 'rx-theme' ), true ),
			'rx_theme_single_show_author'         => array( esc_html__( 'Show Author', 'rx-theme' ), true ),
			'rx_theme_single_show_date'           => array( esc_html__( 'Show Date', 'rx-theme' ), true ),
			'rx_theme_single_show_tags'           => array( esc_html__( 'Show Tags', 'rx-theme' ), true ),
			'rx_theme_single_show_share'          => array( esc_html__( 'Show Social Share', 'rx-theme' ), true ),
			'rx_theme_single_show_author_box'     => array( esc_html__( 'Show Author Box', 'rx-theme' ), true ),
			'rx_theme_single_show_prev_next'      => array( esc_html__( 'Show Previous / Next Post', 'rx-theme' ), true ),
			'rx_theme_single_show_related'        => array( esc_html__( 'Show Related Posts', 'rx-theme' ), true ),
			'rx_theme_single_show_toc'            => array( esc_html__( 'Show Table of Contents', 'rx-theme' ), false ),
		);

		foreach ( $single_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_single_options',
					'type'    => 'checkbox',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_related_posts_count',
			array(
				'default'           => 3,
				'sanitize_callback' => 'rx_theme_sanitize_number_absint',
			)
		);

		$wp_customize->add_control(
			'rx_theme_related_posts_count',
			array(
				'label'       => esc_html__( 'Related Posts Count', 'rx-theme' ),
				'section'     => 'rx_theme_single_options',
				'type'        => 'number',
				'input_attrs' => array(
					'min' => 2,
					'max' => 12,
				),
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Page Options
		 * ------------------------------------------------------------
		 */

		$page_checkboxes = array(
			'rx_theme_page_show_title'          => array( esc_html__( 'Show Page Title', 'rx-theme' ), true ),
			'rx_theme_page_show_featured_image' => array( esc_html__( 'Show Page Featured Image', 'rx-theme' ), true ),
			'rx_theme_page_show_comments'       => array( esc_html__( 'Show Page Comments', 'rx-theme' ), false ),
		);

		foreach ( $page_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_page_options',
					'type'    => 'checkbox',
				)
			);
		}

		/**
		 * ------------------------------------------------------------
		 * Search Page Options
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_search_placeholder',
			array(
				'default'           => esc_html__( 'Search here...', 'rx-theme' ),
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			'rx_theme_search_placeholder',
			array(
				'label'   => esc_html__( 'Search Placeholder', 'rx-theme' ),
				'section' => 'rx_theme_search_options',
				'type'    => 'text',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_search_no_result_text',
			array(
				'default'           => esc_html__( 'Sorry, no results found.', 'rx-theme' ),
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			'rx_theme_search_no_result_text',
			array(
				'label'   => esc_html__( 'No Result Text', 'rx-theme' ),
				'section' => 'rx_theme_search_options',
				'type'    => 'text',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Breadcrumb Options
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_enable_breadcrumb',
			array(
				'default'           => true,
				'sanitize_callback' => 'rx_theme_sanitize_checkbox',
			)
		);

		$wp_customize->add_control(
			'rx_theme_enable_breadcrumb',
			array(
				'label'   => esc_html__( 'Enable Breadcrumb', 'rx-theme' ),
				'section' => 'rx_theme_breadcrumb_options',
				'type'    => 'checkbox',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_breadcrumb_home_text',
			array(
				'default'           => esc_html__( 'Home', 'rx-theme' ),
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			'rx_theme_breadcrumb_home_text',
			array(
				'label'   => esc_html__( 'Breadcrumb Home Text', 'rx-theme' ),
				'section' => 'rx_theme_breadcrumb_options',
				'type'    => 'text',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * SEO Options
		 * ------------------------------------------------------------
		 */

		$seo_checkboxes = array(
			'rx_theme_enable_basic_meta'       => array( esc_html__( 'Enable Basic Meta Tags', 'rx-theme' ), true ),
			'rx_theme_enable_open_graph'       => array( esc_html__( 'Enable Open Graph Tags', 'rx-theme' ), true ),
			'rx_theme_enable_twitter_cards'    => array( esc_html__( 'Enable Twitter Cards', 'rx-theme' ), true ),
			'rx_theme_enable_canonical_url'    => array( esc_html__( 'Enable Canonical URL', 'rx-theme' ), true ),
			'rx_theme_enable_noindex_search'   => array( esc_html__( 'Noindex Search Pages', 'rx-theme' ), false ),
			'rx_theme_enable_noindex_archive'  => array( esc_html__( 'Noindex Archive Pages', 'rx-theme' ), false ),
		);

		foreach ( $seo_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_seo_options',
					'type'    => 'checkbox',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_default_meta_description',
			array(
				'default'           => get_bloginfo( 'description' ),
				'sanitize_callback' => 'sanitize_textarea_field',
			)
		);

		$wp_customize->add_control(
			'rx_theme_default_meta_description',
			array(
				'label'   => esc_html__( 'Default Meta Description', 'rx-theme' ),
				'section' => 'rx_theme_seo_options',
				'type'    => 'textarea',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Schema Options
		 * ------------------------------------------------------------
		 */

		$schema_checkboxes = array(
			'rx_theme_enable_schema'          => array( esc_html__( 'Enable Schema Markup', 'rx-theme' ), true ),
			'rx_theme_enable_article_schema'  => array( esc_html__( 'Enable Article Schema', 'rx-theme' ), true ),
			'rx_theme_enable_breadcrumb_schema'=> array( esc_html__( 'Enable Breadcrumb Schema', 'rx-theme' ), true ),
			'rx_theme_enable_website_schema'  => array( esc_html__( 'Enable Website Schema', 'rx-theme' ), true ),
			'rx_theme_enable_person_schema'   => array( esc_html__( 'Enable Person Schema', 'rx-theme' ), false ),
		);

		foreach ( $schema_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_schema_options',
					'type'    => 'checkbox',
				)
			);
		}

		/**
		 * ------------------------------------------------------------
		 * Performance Options
		 * ------------------------------------------------------------
		 */

		$performance_checkboxes = array(
			'rx_theme_enable_lazy_load'       => array( esc_html__( 'Enable Native Lazy Load', 'rx-theme' ), true ),
			'rx_theme_enable_defer_js'        => array( esc_html__( 'Defer Theme JavaScript', 'rx-theme' ), false ),
			'rx_theme_enable_remove_emoji'    => array( esc_html__( 'Remove WordPress Emoji Script', 'rx-theme' ), true ),
			'rx_theme_enable_remove_dashicons'=> array( esc_html__( 'Remove Dashicons For Visitors', 'rx-theme' ), false ),
			'rx_theme_enable_preconnect'      => array( esc_html__( 'Enable Preconnect Links', 'rx-theme' ), true ),
			'rx_theme_enable_dns_prefetch'    => array( esc_html__( 'Enable DNS Prefetch Links', 'rx-theme' ), true ),
			'rx_theme_enable_skip_link'       => array( esc_html__( 'Enable Accessibility Skip Link', 'rx-theme' ), true ),
		);

		foreach ( $performance_checkboxes as $id => $data ) {
			$wp_customize->add_setting(
				$id,
				array(
					'default'           => $data[1],
					'sanitize_callback' => 'rx_theme_sanitize_checkbox',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $data[0],
					'section' => 'rx_theme_performance_options',
					'type'    => 'checkbox',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_preconnect_urls',
			array(
				'default'           => "https://fonts.gstatic.com\nhttps://fonts.googleapis.com",
				'sanitize_callback' => 'rx_theme_sanitize_plain_textarea',
			)
		);

		$wp_customize->add_control(
			'rx_theme_preconnect_urls',
			array(
				'label'       => esc_html__( 'Preconnect URLs', 'rx-theme' ),
				'description' => esc_html__( 'One URL per line.', 'rx-theme' ),
				'section'     => 'rx_theme_performance_options',
				'type'        => 'textarea',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_dns_prefetch_urls',
			array(
				'default'           => "//fonts.googleapis.com\n//fonts.gstatic.com",
				'sanitize_callback' => 'rx_theme_sanitize_plain_textarea',
			)
		);

		$wp_customize->add_control(
			'rx_theme_dns_prefetch_urls',
			array(
				'label'       => esc_html__( 'DNS Prefetch URLs', 'rx-theme' ),
				'description' => esc_html__( 'One URL per line. Example: //example.com', 'rx-theme' ),
				'section'     => 'rx_theme_performance_options',
				'type'        => 'textarea',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Social Links
		 * ------------------------------------------------------------
		 */

		$social_links = array(
			'facebook'  => esc_html__( 'Facebook URL', 'rx-theme' ),
			'twitter'   => esc_html__( 'Twitter / X URL', 'rx-theme' ),
			'linkedin'  => esc_html__( 'LinkedIn URL', 'rx-theme' ),
			'youtube'   => esc_html__( 'YouTube URL', 'rx-theme' ),
			'instagram' => esc_html__( 'Instagram URL', 'rx-theme' ),
			'pinterest' => esc_html__( 'Pinterest URL', 'rx-theme' ),
			'github'    => esc_html__( 'GitHub URL', 'rx-theme' ),
			'telegram'  => esc_html__( 'Telegram URL', 'rx-theme' ),
			'whatsapp'  => esc_html__( 'WhatsApp URL', 'rx-theme' ),
		);

		foreach ( $social_links as $network => $label ) {
			$id = 'rx_theme_social_' . $network;

			$wp_customize->add_setting(
				$id,
				array(
					'default'           => '',
					'sanitize_callback' => 'rx_theme_sanitize_url',
				)
			);

			$wp_customize->add_control(
				$id,
				array(
					'label'   => $label,
					'section' => 'rx_theme_social_options',
					'type'    => 'url',
				)
			);
		}

		$wp_customize->add_setting(
			'rx_theme_social_open_new_tab',
			array(
				'default'           => true,
				'sanitize_callback' => 'rx_theme_sanitize_checkbox',
			)
		);

		$wp_customize->add_control(
			'rx_theme_social_open_new_tab',
			array(
				'label'   => esc_html__( 'Open Social Links In New Tab', 'rx-theme' ),
				'section' => 'rx_theme_social_options',
				'type'    => 'checkbox',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Notice Bar
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_enable_notice_bar',
			array(
				'default'           => false,
				'sanitize_callback' => 'rx_theme_sanitize_checkbox',
			)
		);

		$wp_customize->add_control(
			'rx_theme_enable_notice_bar',
			array(
				'label'   => esc_html__( 'Enable Notice Bar', 'rx-theme' ),
				'section' => 'rx_theme_notice_options',
				'type'    => 'checkbox',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_notice_text',
			array(
				'default'           => esc_html__( 'Important notice text here.', 'rx-theme' ),
				'sanitize_callback' => 'rx_theme_sanitize_html_limited',
			)
		);

		$wp_customize->add_control(
			'rx_theme_notice_text',
			array(
				'label'   => esc_html__( 'Notice Text', 'rx-theme' ),
				'section' => 'rx_theme_notice_options',
				'type'    => 'textarea',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_notice_button_text',
			array(
				'default'           => esc_html__( 'Learn More', 'rx-theme' ),
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			'rx_theme_notice_button_text',
			array(
				'label'   => esc_html__( 'Notice Button Text', 'rx-theme' ),
				'section' => 'rx_theme_notice_options',
				'type'    => 'text',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_notice_button_url',
			array(
				'default'           => '#',
				'sanitize_callback' => 'rx_theme_sanitize_url',
			)
		);

		$wp_customize->add_control(
			'rx_theme_notice_button_url',
			array(
				'label'   => esc_html__( 'Notice Button URL', 'rx-theme' ),
				'section' => 'rx_theme_notice_options',
				'type'    => 'url',
			)
		);

		/**
		 * ------------------------------------------------------------
		 * Custom Code
		 * ------------------------------------------------------------
		 */

		$wp_customize->add_setting(
			'rx_theme_custom_css',
			array(
				'default'           => '',
				'sanitize_callback' => 'rx_theme_sanitize_css',
			)
		);

		$wp_customize->add_control(
			'rx_theme_custom_css',
			array(
				'label'       => esc_html__( 'Extra Custom CSS', 'rx-theme' ),
				'description' => esc_html__( 'CSS only. Do not add <style> tag.', 'rx-theme' ),
				'section'     => 'rx_theme_custom_code_options',
				'type'        => 'textarea',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_header_custom_html',
			array(
				'default'           => '',
				'sanitize_callback' => 'rx_theme_sanitize_html_limited',
			)
		);

		$wp_customize->add_control(
			'rx_theme_header_custom_html',
			array(
				'label'       => esc_html__( 'Header Custom HTML', 'rx-theme' ),
				'description' => esc_html__( 'Limited safe HTML only.', 'rx-theme' ),
				'section'     => 'rx_theme_custom_code_options',
				'type'        => 'textarea',
			)
		);

		$wp_customize->add_setting(
			'rx_theme_footer_custom_html',
			array(
				'default'           => '',
				'sanitize_callback' => 'rx_theme_sanitize_html_limited',
			)
		);

		$wp_customize->add_control(
			'rx_theme_footer_custom_html',
			array(
				'label'       => esc_html__( 'Footer Custom HTML', 'rx-theme' ),
				'description' => esc_html__( 'Limited safe HTML only.', 'rx-theme' ),
				'section'     => 'rx_theme_custom_code_options',
				'type'        => 'textarea',
			)
		);
	}
}
add_action( 'customize_register', 'rx_theme_customize_register' );

/**
 * ------------------------------------------------------------
 * Selective Refresh Render Callbacks
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_customize_partial_blogname' ) ) {
	function rx_theme_customize_partial_blogname() {
		bloginfo( 'name' );
	}
}

if ( ! function_exists( 'rx_theme_customize_partial_blogdescription' ) ) {
	function rx_theme_customize_partial_blogdescription() {
		bloginfo( 'description' );
	}
}

/**
 * ------------------------------------------------------------
 * Customizer Preview JS
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_customize_preview_js' ) ) {
	function rx_theme_customize_preview_js() {
		wp_enqueue_script(
			'rx-theme-customizer-preview',
			get_template_directory_uri() . '/assets/js/customizer-preview.js',
			array( 'customize-preview' ),
			wp_get_theme()->get( 'Version' ),
			true
		);
	}
}
add_action( 'customize_preview_init', 'rx_theme_customize_preview_js' );

/**
 * ------------------------------------------------------------
 * Output Dynamic CSS
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_dynamic_customizer_css' ) ) {

	function rx_theme_dynamic_customizer_css() {
		$primary_color       = get_theme_mod( 'rx_theme_primary_color', '#2563eb' );
		$secondary_color     = get_theme_mod( 'rx_theme_secondary_color', '#0f172a' );
		$accent_color        = get_theme_mod( 'rx_theme_accent_color', '#16a34a' );
		$body_bg             = get_theme_mod( 'rx_theme_body_bg_color', '#ffffff' );
		$body_text           = get_theme_mod( 'rx_theme_body_text_color', '#1f2937' );
		$heading_color       = get_theme_mod( 'rx_theme_heading_color', '#111827' );
		$link_color          = get_theme_mod( 'rx_theme_link_color', '#2563eb' );
		$link_hover_color    = get_theme_mod( 'rx_theme_link_hover_color', '#1d4ed8' );
		$header_bg           = get_theme_mod( 'rx_theme_header_bg_color', '#ffffff' );
		$footer_bg           = get_theme_mod( 'rx_theme_footer_bg_color', '#020617' );
		$footer_text         = get_theme_mod( 'rx_theme_footer_text_color', '#e5e7eb' );
		$container_width     = absint( get_theme_mod( 'rx_theme_container_width', 1200 ) );
		$content_padding_top = absint( get_theme_mod( 'rx_theme_content_padding_top', 40 ) );
		$content_padding_bot = absint( get_theme_mod( 'rx_theme_content_padding_bottom', 40 ) );
		$card_radius         = absint( get_theme_mod( 'rx_theme_card_border_radius', 12 ) );
		$button_radius       = absint( get_theme_mod( 'rx_theme_button_radius', 8 ) );
		$logo_width          = absint( get_theme_mod( 'rx_theme_logo_width', 180 ) );
		$body_font_size      = absint( get_theme_mod( 'rx_theme_body_font_size', 16 ) );
		$body_line_height    = floatval( get_theme_mod( 'rx_theme_body_line_height', 1.7 ) );
		$h1_font_size        = absint( get_theme_mod( 'rx_theme_h1_font_size', 42 ) );
		$h2_font_size        = absint( get_theme_mod( 'rx_theme_h2_font_size', 34 ) );
		$h3_font_size        = absint( get_theme_mod( 'rx_theme_h3_font_size', 28 ) );
		$custom_css          = get_theme_mod( 'rx_theme_custom_css', '' );

		$css = "
			:root {
				--rx-primary-color: {$primary_color};
				--rx-secondary-color: {$secondary_color};
				--rx-accent-color: {$accent_color};
				--rx-body-bg-color: {$body_bg};
				--rx-body-text-color: {$body_text};
				--rx-heading-color: {$heading_color};
				--rx-link-color: {$link_color};
				--rx-link-hover-color: {$link_hover_color};
				--rx-header-bg-color: {$header_bg};
				--rx-footer-bg-color: {$footer_bg};
				--rx-footer-text-color: {$footer_text};
				--rx-container-width: {$container_width}px;
				--rx-content-padding-top: {$content_padding_top}px;
				--rx-content-padding-bottom: {$content_padding_bot}px;
				--rx-card-radius: {$card_radius}px;
				--rx-button-radius: {$button_radius}px;
				--rx-logo-width: {$logo_width}px;
				--rx-body-font-size: {$body_font_size}px;
				--rx-body-line-height: {$body_line_height};
				--rx-h1-font-size: {$h1_font_size}px;
				--rx-h2-font-size: {$h2_font_size}px;
				--rx-h3-font-size: {$h3_font_size}px;
			}

			body {
				background-color: var(--rx-body-bg-color);
				color: var(--rx-body-text-color);
				font-size: var(--rx-body-font-size);
				line-height: var(--rx-body-line-height);
			}

			a {
				color: var(--rx-link-color);
			}

			a:hover {
				color: var(--rx-link-hover-color);
			}

			h1, h2, h3, h4, h5, h6 {
				color: var(--rx-heading-color);
			}

			h1 {
				font-size: var(--rx-h1-font-size);
			}

			h2 {
				font-size: var(--rx-h2-font-size);
			}

			h3 {
				font-size: var(--rx-h3-font-size);
			}

			.site-header {
				background-color: var(--rx-header-bg-color);
			}

			.site-footer {
				background-color: var(--rx-footer-bg-color);
				color: var(--rx-footer-text-color);
			}

			.site-footer a {
				color: var(--rx-footer-text-color);
			}

			.rx-container,
			.site-container,
			.container {
				max-width: var(--rx-container-width);
			}

			.site-main {
				padding-top: var(--rx-content-padding-top);
				padding-bottom: var(--rx-content-padding-bottom);
			}

			.custom-logo {
				max-width: var(--rx-logo-width);
				height: auto;
			}

			button,
			.button,
			.wp-block-button__link,
			input[type='submit'] {
				border-radius: var(--rx-button-radius);
			}

			.post,
			.page,
			.rx-card,
			.widget {
				border-radius: var(--rx-card-radius);
			}
		";

		if ( ! empty( $custom_css ) ) {
			$css .= "\n" . $custom_css;
		}

		wp_register_style( 'rx-theme-dynamic-style', false, array(), wp_get_theme()->get( 'Version' ) );
		wp_enqueue_style( 'rx-theme-dynamic-style' );
		wp_add_inline_style( 'rx-theme-dynamic-style', $css );
	}
}
add_action( 'wp_enqueue_scripts', 'rx_theme_dynamic_customizer_css', 20 );

/**
 * ------------------------------------------------------------
 * Body Classes From Customizer
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_customizer_body_classes' ) ) {

	function rx_theme_customizer_body_classes( $classes ) {
		$site_layout     = get_theme_mod( 'rx_theme_site_layout', 'full-width' );
		$sidebar_layout  = get_theme_mod( 'rx_theme_sidebar_layout', 'content-sidebar' );
		$header_layout   = get_theme_mod( 'rx_theme_header_layout', 'layout-1' );
		$blog_layout     = get_theme_mod( 'rx_theme_blog_layout', 'grid' );
		$button_style    = get_theme_mod( 'rx_theme_button_style', 'rounded' );
		$dark_mode       = get_theme_mod( 'rx_theme_enable_dark_mode', false );

		$classes[] = 'rx-site-layout-' . sanitize_html_class( $site_layout );
		$classes[] = 'rx-sidebar-layout-' . sanitize_html_class( $sidebar_layout );
		$classes[] = 'rx-header-' . sanitize_html_class( $header_layout );
		$classes[] = 'rx-blog-' . sanitize_html_class( $blog_layout );
		$classes[] = 'rx-button-' . sanitize_html_class( $button_style );

		if ( $dark_mode ) {
			$classes[] = 'rx-dark-mode-enabled';
		}

		return $classes;
	}
}
add_filter( 'body_class', 'rx_theme_customizer_body_classes' );

/**
 * ------------------------------------------------------------
 * Performance Hooks
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_disable_wp_emojis' ) ) {
	function rx_theme_disable_wp_emojis() {
		if ( ! get_theme_mod( 'rx_theme_enable_remove_emoji', true ) ) {
			return;
		}

		remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
		remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
		remove_action( 'wp_print_styles', 'print_emoji_styles' );
		remove_action( 'admin_print_styles', 'print_emoji_styles' );
		remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
		remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
		remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
	}
}
add_action( 'init', 'rx_theme_disable_wp_emojis' );

if ( ! function_exists( 'rx_theme_remove_dashicons_for_visitors' ) ) {
	function rx_theme_remove_dashicons_for_visitors() {
		if ( get_theme_mod( 'rx_theme_enable_remove_dashicons', false ) && ! is_user_logged_in() ) {
			wp_dequeue_style( 'dashicons' );
		}
	}
}
add_action( 'wp_enqueue_scripts', 'rx_theme_remove_dashicons_for_visitors', 100 );

/**
 * ------------------------------------------------------------
 * Resource Hints: DNS Prefetch / Preconnect
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_resource_hints' ) ) {

	function rx_theme_resource_hints( $urls, $relation_type ) {
		if ( 'preconnect' === $relation_type && get_theme_mod( 'rx_theme_enable_preconnect', true ) ) {
			$preconnect_urls = get_theme_mod( 'rx_theme_preconnect_urls', "https://fonts.gstatic.com\nhttps://fonts.googleapis.com" );
			$lines           = array_filter( array_map( 'trim', explode( "\n", $preconnect_urls ) ) );

			foreach ( $lines as $line ) {
				$urls[] = esc_url( $line );
			}
		}

		if ( 'dns-prefetch' === $relation_type && get_theme_mod( 'rx_theme_enable_dns_prefetch', true ) ) {
			$dns_urls = get_theme_mod( 'rx_theme_dns_prefetch_urls', "//fonts.googleapis.com\n//fonts.gstatic.com" );
			$lines    = array_filter( array_map( 'trim', explode( "\n", $dns_urls ) ) );

			foreach ( $lines as $line ) {
				$urls[] = esc_url( $line );
			}
		}

		return array_unique( $urls );
	}
}
add_filter( 'wp_resource_hints', 'rx_theme_resource_hints', 10, 2 );

/**
 * ------------------------------------------------------------
 * Excerpt Length
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_custom_excerpt_length' ) ) {
	function rx_theme_custom_excerpt_length( $length ) {
		return absint( get_theme_mod( 'rx_theme_excerpt_length', 30 ) );
	}
}
add_filter( 'excerpt_length', 'rx_theme_custom_excerpt_length', 20 );

/**
 * ------------------------------------------------------------
 * Read More Text
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_excerpt_more' ) ) {
	function rx_theme_excerpt_more( $more ) {
		return '...';
	}
}
add_filter( 'excerpt_more', 'rx_theme_excerpt_more' );

/**
 * ------------------------------------------------------------
 * Simple SEO Meta Output
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_basic_seo_meta' ) ) {

	function rx_theme_basic_seo_meta() {
		if ( ! get_theme_mod( 'rx_theme_enable_basic_meta', true ) ) {
			return;
		}

		$description = get_theme_mod( 'rx_theme_default_meta_description', get_bloginfo( 'description' ) );

		if ( is_singular() ) {
			global $post;

			if ( $post instanceof WP_Post ) {
				$excerpt = has_excerpt( $post ) ? $post->post_excerpt : wp_trim_words( wp_strip_all_tags( $post->post_content ), 28 );
				if ( ! empty( $excerpt ) ) {
					$description = $excerpt;
				}
			}
		}

		if ( $description ) {
			echo '<meta name="description" content="' . esc_attr( $description ) . '">' . "\n";
		}

		if ( get_theme_mod( 'rx_theme_enable_canonical_url', true ) ) {
			if ( is_singular() ) {
				echo '<link rel="canonical" href="' . esc_url( get_permalink() ) . '">' . "\n";
			} elseif ( is_home() || is_front_page() ) {
				echo '<link rel="canonical" href="' . esc_url( home_url( '/' ) ) . '">' . "\n";
			}
		}

		if ( get_theme_mod( 'rx_theme_enable_noindex_search', false ) && is_search() ) {
			echo '<meta name="robots" content="noindex,follow">' . "\n";
		}

		if ( get_theme_mod( 'rx_theme_enable_noindex_archive', false ) && is_archive() ) {
			echo '<meta name="robots" content="noindex,follow">' . "\n";
		}
	}
}
add_action( 'wp_head', 'rx_theme_basic_seo_meta', 2 );

/**
 * ------------------------------------------------------------
 * Open Graph / Twitter Card Output
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_social_meta_tags' ) ) {

	function rx_theme_social_meta_tags() {
		$enable_og      = get_theme_mod( 'rx_theme_enable_open_graph', true );
		$enable_twitter = get_theme_mod( 'rx_theme_enable_twitter_cards', true );

		if ( ! $enable_og && ! $enable_twitter ) {
			return;
		}

		$title       = wp_get_document_title();
		$url         = is_singular() ? get_permalink() : home_url( add_query_arg( array(), $GLOBALS['wp']->request ?? '' ) );
		$description = get_theme_mod( 'rx_theme_default_meta_description', get_bloginfo( 'description' ) );
		$image       = '';

		if ( is_singular() ) {
			global $post;

			if ( $post instanceof WP_Post ) {
				$description = has_excerpt( $post ) ? $post->post_excerpt : wp_trim_words( wp_strip_all_tags( $post->post_content ), 28 );
				$image_id    = get_post_thumbnail_id( $post );

				if ( $image_id ) {
					$image = wp_get_attachment_image_url( $image_id, 'large' );
				}
			}
		}

		if ( $enable_og ) {
			echo '<meta property="og:title" content="' . esc_attr( $title ) . '">' . "\n";
			echo '<meta property="og:description" content="' . esc_attr( $description ) . '">' . "\n";
			echo '<meta property="og:url" content="' . esc_url( $url ) . '">' . "\n";
			echo '<meta property="og:site_name" content="' . esc_attr( get_bloginfo( 'name' ) ) . '">' . "\n";
			echo '<meta property="og:type" content="' . ( is_singular() ? 'article' : 'website' ) . '">' . "\n";

			if ( $image ) {
				echo '<meta property="og:image" content="' . esc_url( $image ) . '">' . "\n";
			}
		}

		if ( $enable_twitter ) {
			echo '<meta name="twitter:card" content="summary_large_image">' . "\n";
			echo '<meta name="twitter:title" content="' . esc_attr( $title ) . '">' . "\n";
			echo '<meta name="twitter:description" content="' . esc_attr( $description ) . '">' . "\n";

			if ( $image ) {
				echo '<meta name="twitter:image" content="' . esc_url( $image ) . '">' . "\n";
			}
		}
	}
}
add_action( 'wp_head', 'rx_theme_social_meta_tags', 3 );

/**
 * ------------------------------------------------------------
 * Simple Website Schema
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_schema_markup' ) ) {

	function rx_theme_schema_markup() {
		if ( ! get_theme_mod( 'rx_theme_enable_schema', true ) ) {
			return;
		}

		if ( get_theme_mod( 'rx_theme_enable_website_schema', true ) && ( is_front_page() || is_home() ) ) {
			$schema = array(
				'@context' => 'https://schema.org',
				'@type'    => 'WebSite',
				'name'     => get_bloginfo( 'name' ),
				'url'      => home_url( '/' ),
				'potentialAction' => array(
					'@type'       => 'SearchAction',
					'target'      => home_url( '/?s={search_term_string}' ),
					'query-input' => 'required name=search_term_string',
				),
			);

			echo '<script type="application/ld+json">' . wp_json_encode( $schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) . '</script>' . "\n";
		}

		if ( get_theme_mod( 'rx_theme_enable_article_schema', true ) && is_single() ) {
			global $post;

			if ( $post instanceof WP_Post ) {
				$image_id = get_post_thumbnail_id( $post );
				$image    = $image_id ? wp_get_attachment_image_url( $image_id, 'large' ) : '';

				$schema = array(
					'@context'      => 'https://schema.org',
					'@type'         => 'Article',
					'headline'      => get_the_title( $post ),
					'description'   => has_excerpt( $post ) ? get_the_excerpt( $post ) : wp_trim_words( wp_strip_all_tags( $post->post_content ), 28 ),
					'url'           => get_permalink( $post ),
					'datePublished' => get_the_date( DATE_W3C, $post ),
					'dateModified'  => get_the_modified_date( DATE_W3C, $post ),
					'author'        => array(
						'@type' => 'Person',
						'name'  => get_the_author_meta( 'display_name', $post->post_author ),
					),
					'publisher'     => array(
						'@type' => 'Organization',
						'name'  => get_bloginfo( 'name' ),
					),
				);

				if ( $image ) {
					$schema['image'] = $image;
				}

				echo '<script type="application/ld+json">' . wp_json_encode( $schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) . '</script>' . "\n";
			}
		}
	}
}
add_action( 'wp_head', 'rx_theme_schema_markup', 20 );

/**
 * ------------------------------------------------------------
 * Optional Helpers For Template Files
 * ------------------------------------------------------------
 */

if ( ! function_exists( 'rx_theme_get_mod' ) ) {
	function rx_theme_get_mod( $name, $default = '' ) {
		return get_theme_mod( $name, $default );
	}
}

if ( ! function_exists( 'rx_theme_is_enabled' ) ) {
	function rx_theme_is_enabled( $name, $default = false ) {
		return (bool) get_theme_mod( $name, $default );
	}
}

Important next file: assets/js/customizer-preview.js

Because the PHP file enqueues this preview file, create:

rx-theme/
└── assets/
    └── js/
        └── customizer-preview.js

Add this:

(function ($) {
	'use strict';

	wp.customize('blogname', function (value) {
		value.bind(function (newval) {
			$('.site-title a').text(newval);
		});
	});

	wp.customize('blogdescription', function (value) {
		value.bind(function (newval) {
			$('.site-description').text(newval);
		});
	});

	wp.customize('rx_theme_logo_width', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-logo-width', parseInt(newval, 10) + 'px');
		});
	});

	wp.customize('rx_theme_primary_color', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-primary-color', newval);
		});
	});

	wp.customize('rx_theme_body_bg_color', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-body-bg-color', newval);
		});
	});

	wp.customize('rx_theme_body_text_color', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-body-text-color', newval);
		});
	});

	wp.customize('rx_theme_heading_color', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-heading-color', newval);
		});
	});

	wp.customize('rx_theme_link_color', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-link-color', newval);
		});
	});

	wp.customize('rx_theme_header_bg_color', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-header-bg-color', newval);
		});
	});

	wp.customize('rx_theme_footer_bg_color', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-footer-bg-color', newval);
		});
	});

	wp.customize('rx_theme_container_width', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-container-width', parseInt(newval, 10) + 'px');
		});
	});

	wp.customize('rx_theme_body_font_size', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-body-font-size', parseInt(newval, 10) + 'px');
		});
	});

	wp.customize('rx_theme_body_line_height', function (value) {
		value.bind(function (newval) {
			document.documentElement.style.setProperty('--rx-body-line-height', parseFloat(newval));
		});
	});

})(jQuery);

How to use values inside template files

Example in header.php:

<?php if ( rx_theme_is_enabled( 'rx_theme_enable_topbar', false ) ) : ?>
	<div class="rx-topbar">
		<?php echo wp_kses_post( rx_theme_get_mod( 'rx_theme_topbar_text', 'Welcome to RX Theme' ) ); ?>
	</div>
<?php endif; ?>

Example in single.php:

<?php if ( rx_theme_is_enabled( 'rx_theme_single_show_author_box', true ) ) : ?>
	<div class="rx-author-box">
		<?php get_template_part( 'template-parts/single/author-box' ); ?>
	</div>
<?php endif; ?>

Example in footer.php:

<?php if ( rx_theme_is_enabled( 'rx_theme_enable_copyright', true ) ) : ?>
	<div class="rx-copyright">
		<?php echo wp_kses_post( rx_theme_get_mod( 'rx_theme_footer_copyright' ) ); ?>
	</div>
<?php endif; ?>

This file gives your rx theme a strong Customizer system. It stores options safely, outputs dynamic CSS, adds SEO/meta/schema basics, performance toggles, resource hints, blog controls, header/footer controls, and helper functions for your theme templates.

single.php – it is not find in theme structure

No problem, friend. In a WordPress theme, single.php is optional, but it is very useful for single blog post pages.

If your rx theme does not have it, create this file in the root theme folder:

rx-theme/
├── functions.php
├── style.css
├── index.php
├── header.php
├── footer.php
├── sidebar.php
└── single.php   ← create this file

Create single.php

<?php
/**
 * Single Post Template
 *
 * This file controls single blog post pages.
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();
?>

<main id="primary" class="site-main rx-single-main">

	<div class="rx-container rx-single-container">

		<?php
		if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_enable_breadcrumb', true ) ) {
			if ( function_exists( 'rx_theme_breadcrumb' ) ) {
				rx_theme_breadcrumb();
			}
		}
		?>

		<?php
		while ( have_posts() ) :
			the_post();
			?>

			<article id="post-<?php the_ID(); ?>" <?php post_class( 'rx-single-post' ); ?>>

				<header class="rx-single-header">

					<?php
					if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_category', true ) ) :
						?>
						<div class="rx-single-category">
							<?php the_category( ' ' ); ?>
						</div>
					<?php endif; ?>

					<h1 class="rx-single-title">
						<?php the_title(); ?>
					</h1>

					<div class="rx-single-meta">

						<?php
						if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_author', true ) ) :
							?>
							<span class="rx-single-author">
								<?php esc_html_e( 'By', 'rx-theme' ); ?>
								<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
									<?php echo esc_html( get_the_author() ); ?>
								</a>
							</span>
						<?php endif; ?>

						<?php
						if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_date', true ) ) :
							?>
							<span class="rx-single-date">
								<?php echo esc_html( get_the_date() ); ?>
							</span>
						<?php endif; ?>

					</div>

				</header>

				<?php
				if (
					function_exists( 'rx_theme_is_enabled' )
					&& rx_theme_is_enabled( 'rx_theme_single_show_featured_image', true )
					&& has_post_thumbnail()
				) :
					?>
					<div class="rx-single-thumbnail">
						<?php the_post_thumbnail( 'large' ); ?>
					</div>
				<?php endif; ?>

				<div class="rx-single-content entry-content">

					<?php
					the_content();

					wp_link_pages(
						array(
							'before' => '<div class="rx-page-links">' . esc_html__( 'Pages:', 'rx-theme' ),
							'after'  => '</div>',
						)
					);
					?>

				</div>

				<?php
				if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_tags', true ) ) :
					$tags = get_the_tag_list( '', ' ', '' );

					if ( $tags ) :
						?>
						<footer class="rx-single-footer">
							<div class="rx-single-tags">
								<span><?php esc_html_e( 'Tags:', 'rx-theme' ); ?></span>
								<?php echo wp_kses_post( $tags ); ?>
							</div>
						</footer>
					<?php endif; ?>
				<?php endif; ?>

			</article>

			<?php
			if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_author_box', true ) ) :
				get_template_part( 'template-parts/single/author-box' );
			endif;

			if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_prev_next', true ) ) :
				?>
				<nav class="rx-post-navigation">
					<div class="rx-post-prev">
						<?php previous_post_link( '%link', esc_html__( '← Previous Post', 'rx-theme' ) ); ?>
					</div>

					<div class="rx-post-next">
						<?php next_post_link( '%link', esc_html__( 'Next Post →', 'rx-theme' ) ); ?>
					</div>
				</nav>
				<?php
			endif;

			if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_related', true ) ) :
				get_template_part( 'template-parts/single/related-posts' );
			endif;

			if ( comments_open() || get_comments_number() ) :
				comments_template();
			endif;

		endwhile;
		?>

	</div>

</main>

<?php
get_footer();

Also create optional folders

Because this single.php uses template parts, create these folders/files:

rx-theme/
└── template-parts/
    └── single/
        ├── author-box.php
        └── related-posts.php

template-parts/single/author-box.php

<?php
/**
 * Author Box Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$author_id          = get_the_author_meta( 'ID' );
$author_name        = get_the_author_meta( 'display_name', $author_id );
$author_description = get_the_author_meta( 'description', $author_id );
$author_url         = get_author_posts_url( $author_id );
?>

<div class="rx-author-box">

	<div class="rx-author-avatar">
		<?php echo get_avatar( $author_id, 96 ); ?>
	</div>

	<div class="rx-author-content">

		<h3 class="rx-author-title">
			<a href="<?php echo esc_url( $author_url ); ?>">
				<?php echo esc_html( $author_name ); ?>
			</a>
		</h3>

		<?php if ( $author_description ) : ?>
			<p class="rx-author-description">
				<?php echo esc_html( $author_description ); ?>
			</p>
		<?php endif; ?>

	</div>

</div>

template-parts/single/related-posts.php

<?php
/**
 * Related Posts Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$post_id = get_the_ID();

$categories = wp_get_post_categories( $post_id );

if ( empty( $categories ) ) {
	return;
}

$count = function_exists( 'rx_theme_get_mod' ) ? absint( rx_theme_get_mod( 'rx_theme_related_posts_count', 3 ) ) : 3;

$related_query = new WP_Query(
	array(
		'post_type'           => 'post',
		'posts_per_page'      => $count,
		'post__not_in'        => array( $post_id ),
		'category__in'        => $categories,
		'ignore_sticky_posts' => true,
	)
);

if ( ! $related_query->have_posts() ) {
	wp_reset_postdata();
	return;
}
?>

<section class="rx-related-posts">

	<h2 class="rx-related-title">
		<?php esc_html_e( 'Related Posts', 'rx-theme' ); ?>
	</h2>

	<div class="rx-related-grid">

		<?php
		while ( $related_query->have_posts() ) :
			$related_query->the_post();
			?>

			<article id="related-post-<?php the_ID(); ?>" <?php post_class( 'rx-related-card' ); ?>>

				<?php if ( has_post_thumbnail() ) : ?>
					<a class="rx-related-thumb" href="<?php the_permalink(); ?>">
						<?php the_post_thumbnail( 'medium_large' ); ?>
					</a>
				<?php endif; ?>

				<h3 class="rx-related-post-title">
					<a href="<?php the_permalink(); ?>">
						<?php the_title(); ?>
					</a>
				</h3>

				<div class="rx-related-meta">
					<?php echo esc_html( get_the_date() ); ?>
				</div>

			</article>

		<?php endwhile; ?>

	</div>

</section>

<?php
wp_reset_postdata();

Add basic CSS in style.css

.rx-single-container {
	max-width: 900px;
	margin-left: auto;
	margin-right: auto;
	padding: 40px 20px;
}

.rx-single-post {
	background: #fff;
}

.rx-single-category {
	margin-bottom: 12px;
}

.rx-single-category a {
	display: inline-block;
	margin-right: 8px;
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--rx-primary-color, #2563eb);
	color: #fff;
	text-decoration: none;
	font-size: 13px;
}

.rx-single-title {
	margin: 0 0 16px;
	line-height: 1.2;
}

.rx-single-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 24px;
	color: #6b7280;
	font-size: 14px;
}

.rx-single-thumbnail {
	margin-bottom: 30px;
}

.rx-single-thumbnail img {
	width: 100%;
	height: auto;
	border-radius: var(--rx-card-radius, 12px);
}

.rx-single-content {
	font-size: 18px;
	line-height: 1.8;
}

.rx-single-content img {
	max-width: 100%;
	height: auto;
}

.rx-single-tags {
	margin-top: 30px;
}

.rx-single-tags a {
	display: inline-block;
	margin: 4px;
	padding: 5px 10px;
	background: #f3f4f6;
	border-radius: 999px;
	text-decoration: none;
}

.rx-author-box {
	display: flex;
	gap: 20px;
	margin-top: 40px;
	padding: 24px;
	background: #f9fafb;
	border-radius: var(--rx-card-radius, 12px);
}

.rx-author-avatar img {
	border-radius: 50%;
}

.rx-author-title {
	margin-top: 0;
	margin-bottom: 8px;
}

.rx-post-navigation {
	display: flex;
	justify-content: space-between;
	gap: 20px;
	margin-top: 40px;
	padding-top: 24px;
	border-top: 1px solid #e5e7eb;
}

.rx-related-posts {
	margin-top: 50px;
}

.rx-related-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 24px;
}

.rx-related-card {
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: var(--rx-card-radius, 12px);
	overflow: hidden;
}

.rx-related-thumb img {
	width: 100%;
	height: auto;
	display: block;
}

.rx-related-post-title {
	padding: 16px 16px 4px;
	margin: 0;
	font-size: 18px;
}

.rx-related-meta {
	padding: 0 16px 16px;
	color: #6b7280;
	font-size: 14px;
}

@media (max-width: 768px) {
	.rx-related-grid {
		grid-template-columns: 1fr;
	}

	.rx-post-navigation {
		flex-direction: column;
	}

	.rx-author-box {
		flex-direction: column;
	}
}

Important

Your theme can still work without single.php because WordPress falls back to index.php.

But for a professional theme, you should create:

single.php
page.php
archive.php
search.php
404.php
comments.php

For now, create single.php first. Then your Customizer single post options will have a proper place to work.

single.php page.php archive.php search.php 404.php comments.php structure will what

Yes friend, these files should be in the root folder of your rx theme.

Recommended theme structure

rx-theme/
├── style.css
├── functions.php
├── index.php
├── header.php
├── footer.php
├── sidebar.php
├── single.php
├── page.php
├── archive.php
├── search.php
├── 404.php
├── comments.php
│
├── inc/
│   └── options/
│       └── customizer.php
│
├── template-parts/
│   ├── content.php
│   ├── content-page.php
│   ├── content-none.php
│   ├── content-search.php
│   │
│   └── single/
│       ├── author-box.php
│       └── related-posts.php
│
└── assets/
    ├── css/
    │   └── main.css
    └── js/
        └── customizer-preview.js

1. single.php

For single blog post page.

<?php
/**
 * Single Post Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();
?>

<main id="primary" class="site-main rx-single-main">

	<div class="rx-container rx-single-container">

		<?php
		while ( have_posts() ) :
			the_post();

			get_template_part( 'template-parts/content', get_post_type() );

			if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_author_box', true ) ) {
				get_template_part( 'template-parts/single/author-box' );
			}

			if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_prev_next', true ) ) :
				?>
				<nav class="rx-post-navigation">
					<div class="rx-post-prev">
						<?php previous_post_link( '%link', esc_html__( '← Previous Post', 'rx-theme' ) ); ?>
					</div>

					<div class="rx-post-next">
						<?php next_post_link( '%link', esc_html__( 'Next Post →', 'rx-theme' ) ); ?>
					</div>
				</nav>
				<?php
			endif;

			if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_related', true ) ) {
				get_template_part( 'template-parts/single/related-posts' );
			}

			if ( comments_open() || get_comments_number() ) {
				comments_template();
			}

		endwhile;
		?>

	</div>

</main>

<?php
get_footer();

2. page.php

For normal WordPress pages.

<?php
/**
 * Page Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();
?>

<main id="primary" class="site-main rx-page-main">

	<div class="rx-container rx-page-container">

		<?php
		while ( have_posts() ) :
			the_post();

			get_template_part( 'template-parts/content', 'page' );

			if (
				comments_open()
				|| get_comments_number()
			) {
				if ( function_exists( 'rx_theme_is_enabled' ) ) {
					if ( rx_theme_is_enabled( 'rx_theme_page_show_comments', false ) ) {
						comments_template();
					}
				} else {
					comments_template();
				}
			}

		endwhile;
		?>

	</div>

</main>

<?php
get_footer();

3. archive.php

For category, tag, author, date, and custom post archives.

<?php
/**
 * Archive Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();
?>

<main id="primary" class="site-main rx-archive-main">

	<div class="rx-container rx-archive-container">

		<header class="rx-archive-header">
			<?php
			the_archive_title( '<h1 class="rx-archive-title">', '</h1>' );
			the_archive_description( '<div class="rx-archive-description">', '</div>' );
			?>
		</header>

		<?php if ( have_posts() ) : ?>

			<div class="rx-post-grid rx-archive-grid">

				<?php
				while ( have_posts() ) :
					the_post();

					get_template_part( 'template-parts/content', get_post_type() );

				endwhile;
				?>

			</div>

			<div class="rx-pagination">
				<?php
				the_posts_pagination(
					array(
						'mid_size'  => 2,
						'prev_text' => esc_html__( '← Previous', 'rx-theme' ),
						'next_text' => esc_html__( 'Next →', 'rx-theme' ),
					)
				);
				?>
			</div>

		<?php else : ?>

			<?php get_template_part( 'template-parts/content', 'none' ); ?>

		<?php endif; ?>

	</div>

</main>

<?php
get_footer();

4. search.php

For search result page.

<?php
/**
 * Search Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();
?>

<main id="primary" class="site-main rx-search-main">

	<div class="rx-container rx-search-container">

		<header class="rx-search-header">
			<h1 class="rx-search-title">
				<?php
				printf(
					esc_html__( 'Search Results for: %s', 'rx-theme' ),
					'<span>' . esc_html( get_search_query() ) . '</span>'
				);
				?>
			</h1>

			<div class="rx-search-form-wrap">
				<?php get_search_form(); ?>
			</div>
		</header>

		<?php if ( have_posts() ) : ?>

			<div class="rx-post-grid rx-search-grid">

				<?php
				while ( have_posts() ) :
					the_post();

					get_template_part( 'template-parts/content', 'search' );

				endwhile;
				?>

			</div>

			<div class="rx-pagination">
				<?php
				the_posts_pagination(
					array(
						'mid_size'  => 2,
						'prev_text' => esc_html__( '← Previous', 'rx-theme' ),
						'next_text' => esc_html__( 'Next →', 'rx-theme' ),
					)
				);
				?>
			</div>

		<?php else : ?>

			<?php get_template_part( 'template-parts/content', 'none' ); ?>

		<?php endif; ?>

	</div>

</main>

<?php
get_footer();

5. 404.php

For not found page.

<?php
/**
 * 404 Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();
?>

<main id="primary" class="site-main rx-404-main">

	<div class="rx-container rx-404-container">

		<section class="rx-error-404 not-found">

			<header class="rx-404-header">
				<h1 class="rx-404-title">
					<?php esc_html_e( '404', 'rx-theme' ); ?>
				</h1>

				<h2 class="rx-404-subtitle">
					<?php esc_html_e( 'Page Not Found', 'rx-theme' ); ?>
				</h2>
			</header>

			<div class="rx-404-content">
				<p>
					<?php esc_html_e( 'Sorry, the page you are looking for does not exist, has been moved, or is temporarily unavailable.', 'rx-theme' ); ?>
				</p>

				<div class="rx-404-search">
					<?php get_search_form(); ?>
				</div>

				<a class="rx-button rx-404-home-button" href="<?php echo esc_url( home_url( '/' ) ); ?>">
					<?php esc_html_e( 'Back to Home', 'rx-theme' ); ?>
				</a>
			</div>

		</section>

	</div>

</main>

<?php
get_footer();

6. comments.php

For comments section.

<?php
/**
 * Comments Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( post_password_required() ) {
	return;
}
?>

<div id="comments" class="comments-area rx-comments-area">

	<?php if ( have_comments() ) : ?>

		<h2 class="comments-title rx-comments-title">
			<?php
			$rx_comment_count = get_comments_number();

			if ( '1' === $rx_comment_count ) {
				printf(
					esc_html__( 'One comment on “%s”', 'rx-theme' ),
					'<span>' . wp_kses_post( get_the_title() ) . '</span>'
				);
			} else {
				printf(
					esc_html(
						_nx(
							'%1$s comment on “%2$s”',
							'%1$s comments on “%2$s”',
							$rx_comment_count,
							'comments title',
							'rx-theme'
						)
					),
					number_format_i18n( $rx_comment_count ),
					'<span>' . wp_kses_post( get_the_title() ) . '</span>'
				);
			}
			?>
		</h2>

		<ol class="comment-list rx-comment-list">
			<?php
			wp_list_comments(
				array(
					'style'      => 'ol',
					'short_ping' => true,
					'avatar_size'=> 64,
				)
			);
			?>
		</ol>

		<?php
		the_comments_navigation(
			array(
				'prev_text' => esc_html__( '← Older Comments', 'rx-theme' ),
				'next_text' => esc_html__( 'Newer Comments →', 'rx-theme' ),
			)
		);
		?>

	<?php endif; ?>

	<?php
	if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
		?>
		<p class="no-comments rx-no-comments">
			<?php esc_html_e( 'Comments are closed.', 'rx-theme' ); ?>
		</p>
	<?php endif; ?>

	<?php
	comment_form(
		array(
			'title_reply'          => esc_html__( 'Leave a Comment', 'rx-theme' ),
			'title_reply_before'   => '<h2 id="reply-title" class="comment-reply-title rx-comment-reply-title">',
			'title_reply_after'    => '</h2>',
			'label_submit'         => esc_html__( 'Post Comment', 'rx-theme' ),
			'class_submit'         => 'submit rx-comment-submit',
			'comment_notes_before' => '',
			'comment_notes_after'  => '',
		)
	);
	?>

</div>

Also create template parts

These make your theme clean and professional.

template-parts/content.php

Used by blog, archive, and single post.

<?php
/**
 * Default Content Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$is_single = is_singular( 'post' );
?>

<article id="post-<?php the_ID(); ?>" <?php post_class( $is_single ? 'rx-single-post' : 'rx-post-card' ); ?>>

	<?php if ( $is_single ) : ?>

		<header class="rx-single-header">

			<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_category', true ) ) : ?>
				<div class="rx-single-category">
					<?php the_category( ' ' ); ?>
				</div>
			<?php endif; ?>

			<h1 class="rx-single-title">
				<?php the_title(); ?>
			</h1>

			<div class="rx-single-meta">
				<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_author', true ) ) : ?>
					<span class="rx-single-author">
						<?php esc_html_e( 'By', 'rx-theme' ); ?>
						<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
							<?php echo esc_html( get_the_author() ); ?>
						</a>
					</span>
				<?php endif; ?>

				<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_date', true ) ) : ?>
					<span class="rx-single-date">
						<?php echo esc_html( get_the_date() ); ?>
					</span>
				<?php endif; ?>
			</div>

		</header>

		<?php
		if (
			function_exists( 'rx_theme_is_enabled' )
			&& rx_theme_is_enabled( 'rx_theme_single_show_featured_image', true )
			&& has_post_thumbnail()
		) :
			?>
			<div class="rx-single-thumbnail">
				<?php the_post_thumbnail( 'large' ); ?>
			</div>
		<?php endif; ?>

		<div class="rx-single-content entry-content">
			<?php
			the_content();

			wp_link_pages(
				array(
					'before' => '<div class="rx-page-links">' . esc_html__( 'Pages:', 'rx-theme' ),
					'after'  => '</div>',
				)
			);
			?>
		</div>

		<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_single_show_tags', true ) ) : ?>
			<?php $tags = get_the_tag_list( '', ' ', '' ); ?>

			<?php if ( $tags ) : ?>
				<footer class="rx-single-footer">
					<div class="rx-single-tags">
						<span><?php esc_html_e( 'Tags:', 'rx-theme' ); ?></span>
						<?php echo wp_kses_post( $tags ); ?>
					</div>
				</footer>
			<?php endif; ?>
		<?php endif; ?>

	<?php else : ?>

		<?php if ( has_post_thumbnail() ) : ?>
			<a class="rx-post-thumbnail" href="<?php the_permalink(); ?>">
				<?php the_post_thumbnail( 'medium_large' ); ?>
			</a>
		<?php endif; ?>

		<div class="rx-post-content-wrap">

			<header class="rx-post-header">

				<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_blog_show_category', true ) ) : ?>
					<div class="rx-post-category">
						<?php the_category( ' ' ); ?>
					</div>
				<?php endif; ?>

				<h2 class="rx-post-title">
					<a href="<?php the_permalink(); ?>">
						<?php the_title(); ?>
					</a>
				</h2>

				<div class="rx-post-meta">
					<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_blog_show_author', true ) ) : ?>
						<span><?php echo esc_html( get_the_author() ); ?></span>
					<?php endif; ?>

					<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_blog_show_date', true ) ) : ?>
						<span><?php echo esc_html( get_the_date() ); ?></span>
					<?php endif; ?>
				</div>

			</header>

			<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_blog_show_excerpt', true ) ) : ?>
				<div class="rx-post-excerpt">
					<?php the_excerpt(); ?>
				</div>
			<?php endif; ?>

			<?php if ( function_exists( 'rx_theme_is_enabled' ) && rx_theme_is_enabled( 'rx_theme_blog_show_read_more', true ) ) : ?>
				<a class="rx-read-more" href="<?php the_permalink(); ?>">
					<?php echo esc_html( function_exists( 'rx_theme_get_mod' ) ? rx_theme_get_mod( 'rx_theme_read_more_text', 'Read More' ) : 'Read More' ); ?>
				</a>
			<?php endif; ?>

		</div>

	<?php endif; ?>

</article>

template-parts/content-page.php

<?php
/**
 * Page Content Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>

<article id="post-<?php the_ID(); ?>" <?php post_class( 'rx-page-content' ); ?>>

	<?php if ( function_exists( 'rx_theme_is_enabled' ) ? rx_theme_is_enabled( 'rx_theme_page_show_title', true ) : true ) : ?>
		<header class="rx-page-header">
			<h1 class="rx-page-title">
				<?php the_title(); ?>
			</h1>
		</header>
	<?php endif; ?>

	<?php
	if (
		function_exists( 'rx_theme_is_enabled' )
		&& rx_theme_is_enabled( 'rx_theme_page_show_featured_image', true )
		&& has_post_thumbnail()
	) :
		?>
		<div class="rx-page-thumbnail">
			<?php the_post_thumbnail( 'large' ); ?>
		</div>
	<?php endif; ?>

	<div class="rx-page-entry entry-content">
		<?php
		the_content();

		wp_link_pages(
			array(
				'before' => '<div class="rx-page-links">' . esc_html__( 'Pages:', 'rx-theme' ),
				'after'  => '</div>',
			)
		);
		?>
	</div>

</article>

template-parts/content-search.php

<?php
/**
 * Search Content Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>

<article id="post-<?php the_ID(); ?>" <?php post_class( 'rx-search-card' ); ?>>

	<header class="rx-search-card-header">
		<h2 class="rx-search-card-title">
			<a href="<?php the_permalink(); ?>">
				<?php the_title(); ?>
			</a>
		</h2>

		<div class="rx-search-card-meta">
			<span><?php echo esc_html( get_post_type() ); ?></span>
			<span><?php echo esc_html( get_the_date() ); ?></span>
		</div>
	</header>

	<div class="rx-search-card-excerpt">
		<?php the_excerpt(); ?>
	</div>

	<a class="rx-read-more" href="<?php the_permalink(); ?>">
		<?php esc_html_e( 'View Result', 'rx-theme' ); ?>
	</a>

</article>

template-parts/content-none.php

<?php
/**
 * No Content Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>

<section class="no-results not-found rx-no-results">

	<header class="rx-no-results-header">
		<h1 class="rx-no-results-title">
			<?php esc_html_e( 'Nothing Found', 'rx-theme' ); ?>
		</h1>
	</header>

	<div class="rx-no-results-content">

		<?php if ( is_home() && current_user_can( 'publish_posts' ) ) : ?>

			<p>
				<?php
				printf(
					wp_kses(
						__( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'rx-theme' ),
						array(
							'a' => array(
								'href' => array(),
							),
						)
					),
					esc_url( admin_url( 'post-new.php' ) )
				);
				?>
			</p>

		<?php elseif ( is_search() ) : ?>

			<p>
				<?php esc_html_e( 'Sorry, but nothing matched your search terms. Please try again with different keywords.', 'rx-theme' ); ?>
			</p>

			<?php get_search_form(); ?>

		<?php else : ?>

			<p>
				<?php esc_html_e( 'It seems we cannot find what you are looking for. Maybe searching can help.', 'rx-theme' ); ?>
			</p>

			<?php get_search_form(); ?>

		<?php endif; ?>

	</div>

</section>

Optional but very useful: searchform.php

Create this also in root folder:

rx-theme/
└── searchform.php
<?php
/**
 * Search Form Template
 *
 * @package RX_Theme
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$placeholder = function_exists( 'rx_theme_get_mod' )
	? rx_theme_get_mod( 'rx_theme_search_placeholder', esc_html__( 'Search here...', 'rx-theme' ) )
	: esc_html__( 'Search here...', 'rx-theme' );
?>

<form role="search" method="get" class="rx-search-form search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
	<label class="screen-reader-text" for="rx-search-field">
		<?php esc_html_e( 'Search for:', 'rx-theme' ); ?>
	</label>

	<input
		type="search"
		id="rx-search-field"
		class="rx-search-field search-field"
		placeholder="<?php echo esc_attr( $placeholder ); ?>"
		value="<?php echo esc_attr( get_search_query() ); ?>"
		name="s"
	/>

	<button type="submit" class="rx-search-submit">
		<?php esc_html_e( 'Search', 'rx-theme' ); ?>
	</button>
</form>

Add this CSS to style.css

.rx-container {
	width: 100%;
	max-width: var(--rx-container-width, 1200px);
	margin-left: auto;
	margin-right: auto;
	padding-left: 20px;
	padding-right: 20px;
}

.rx-post-grid,
.rx-archive-grid,
.rx-search-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 30px;
}

.rx-post-card,
.rx-search-card {
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: var(--rx-card-radius, 12px);
	overflow: hidden;
}

.rx-post-thumbnail img {
	width: 100%;
	height: auto;
	display: block;
}

.rx-post-content-wrap,
.rx-search-card {
	padding: 20px;
}

.rx-post-title,
.rx-search-card-title {
	margin-top: 10px;
	margin-bottom: 10px;
}

.rx-post-title a,
.rx-search-card-title a {
	text-decoration: none;
	color: var(--rx-heading-color, #111827);
}

.rx-post-meta,
.rx-search-card-meta {
	display: flex;
	gap: 10px;
	color: #6b7280;
	font-size: 14px;
	margin-bottom: 12px;
}

.rx-read-more,
.rx-button,
.rx-search-submit,
.rx-comment-submit {
	display: inline-block;
	padding: 10px 18px;
	background: var(--rx-primary-color, #2563eb);
	color: #ffffff;
	border-radius: var(--rx-button-radius, 8px);
	text-decoration: none;
	border: none;
	cursor: pointer;
}

.rx-read-more:hover,
.rx-button:hover,
.rx-search-submit:hover,
.rx-comment-submit:hover {
	background: var(--rx-link-hover-color, #1d4ed8);
	color: #ffffff;
}

.rx-page-container,
.rx-single-container,
.rx-404-container {
	max-width: 900px;
}

.rx-page-title,
.rx-single-title,
.rx-archive-title,
.rx-search-title {
	margin-bottom: 20px;
}

.rx-page-thumbnail,
.rx-single-thumbnail {
	margin-bottom: 30px;
}

.rx-page-thumbnail img,
.rx-single-thumbnail img {
	width: 100%;
	height: auto;
	border-radius: var(--rx-card-radius, 12px);
}

.rx-single-content,
.rx-page-entry {
	font-size: 18px;
	line-height: 1.8;
}

.rx-post-navigation {
	display: flex;
	justify-content: space-between;
	gap: 20px;
	margin-top: 40px;
	padding-top: 24px;
	border-top: 1px solid #e5e7eb;
}

.rx-comments-area {
	margin-top: 50px;
	padding-top: 30px;
	border-top: 1px solid #e5e7eb;
}

.rx-comment-list {
	margin: 0;
	padding-left: 20px;
}

.rx-search-form {
	display: flex;
	gap: 10px;
	margin-top: 20px;
}

.rx-search-field {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid #d1d5db;
	border-radius: var(--rx-button-radius, 8px);
}

.rx-error-404 {
	text-align: center;
	padding: 80px 20px;
}

.rx-404-title {
	font-size: 100px;
	line-height: 1;
	margin: 0;
	color: var(--rx-primary-color, #2563eb);
}

.rx-404-subtitle {
	margin-top: 10px;
}

.rx-404-search {
	max-width: 500px;
	margin: 30px auto;
}

.rx-pagination {
	margin-top: 40px;
	text-align: center;
}

@media (max-width: 992px) {
	.rx-post-grid,
	.rx-archive-grid,
	.rx-search-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 768px) {
	.rx-post-grid,
	.rx-archive-grid,
	.rx-search-grid {
		grid-template-columns: 1fr;
	}

	.rx-search-form {
		flex-direction: column;
	}

	.rx-post-navigation {
		flex-direction: column;
	}

	.rx-404-title {
		font-size: 72px;
	}
}

Final structure after creating all

rx-theme/
├── 404.php
├── archive.php
├── comments.php
├── footer.php
├── functions.php
├── header.php
├── index.php
├── page.php
├── search.php
├── searchform.php
├── sidebar.php
├── single.php
├── style.css
│
├── inc/
│   └── options/
│       └── customizer.php
│
├── template-parts/
│   ├── content.php
│   ├── content-none.php
│   ├── content-page.php
│   ├── content-search.php
│   └── single/
│       ├── author-box.php
│       └── related-posts.php
│
└── assets/
    ├── css/
    │   └── main.css
    └── js/
        └── customizer-preview.js

This structure is clean, professional, and works very well with your inc/options/customizer.php file.

if create fresh new file is it will better,

Yes, friend — creating fresh new files is better for your rx theme.

Because your theme is still growing, fresh files will make the structure cleaner, easier to debug, and more professional.

Use this method:

rx-theme/
├── single.php      ← create fresh
├── page.php        ← create fresh
├── archive.php     ← create fresh
├── search.php      ← create fresh
├── 404.php         ← create fresh
├── comments.php    ← create fresh
└── searchform.php  ← create fresh

Also create fresh template-part files:

rx-theme/
└── template-parts/
    ├── content.php
    ├── content-page.php
    ├── content-search.php
    ├── content-none.php
    └── single/
        ├── author-box.php
        └── related-posts.php

Best safe order:

1. Backup your current theme first.
2. Create the new files.
3. Paste code into each file.
4. Check WordPress Admin → Appearance → Themes.
5. Open one post, one page, one category, one search page, and one wrong URL.
6. If no fatal error appears, then continue improving CSS and layout.

Do not delete index.php. WordPress needs it as the final fallback template.

So your final root files should be:

rx-theme/
├── style.css
├── functions.php
├── index.php
├── header.php
├── footer.php
├── sidebar.php
├── single.php
├── page.php
├── archive.php
├── search.php
├── 404.php
├── comments.php
└── searchform.php

My recommendation: yes, create fresh files. It is better than forcing everything inside index.php. It will make your rx theme more like a real premium WordPress theme.

Leave a Reply

Your email address will not be published. Required fields are marked *