template-full-width.php

I’ll give you a strong, production-style template-full-width.php for RX Theme, with safe WordPress functions, accessibility, schema hooks, Gutenberg support areas, and extension hooks for future development.

Friend, for templates/template-full-width.php, the best advanced template should be clean, safe, full-width, SEO-ready, accessibility-ready, Gutenberg-ready, and future-expandable.

Use this file here:

rx-theme/
└── templates/
    └── template-full-width.php

Paste this full code inside templates/template-full-width.php:

<?php
/**
 * Template Name: RX Full Width
 * Template Post Type: page
 *
 * Advanced full-width page template for RX Theme.
 *
 * This template is designed for:
 * - Full-width landing pages
 * - Medical article hub pages
 * - Custom Gutenberg pages
 * - Elementor / page builder compatible pages
 * - SEO-friendly content pages
 * - Schema-ready page layout
 * - Accessible content structure
 *
 * @package RX_Theme
 * @since 1.0.0
 */

defined( 'ABSPATH' ) || exit;

get_header();

/**
 * Main wrapper classes.
 */
$rx_page_id = get_the_ID();

$rx_wrapper_classes = array(
	'rx-site-main',
	'rx-full-width-template',
	'rx-template-full-width',
);

if ( is_page() ) {
	$rx_wrapper_classes[] = 'rx-page-' . absint( $rx_page_id );
}

if ( has_post_thumbnail() ) {
	$rx_wrapper_classes[] = 'rx-has-featured-image';
} else {
	$rx_wrapper_classes[] = 'rx-no-featured-image';
}

if ( is_user_logged_in() ) {
	$rx_wrapper_classes[] = 'rx-user-logged-in';
}

$rx_wrapper_classes = apply_filters( 'rx_theme_full_width_wrapper_classes', $rx_wrapper_classes, $rx_page_id );

/**
 * Content classes.
 */
$rx_content_classes = array(
	'rx-full-width-content',
	'rx-entry-content-wrap',
);

$rx_content_classes = apply_filters( 'rx_theme_full_width_content_classes', $rx_content_classes, $rx_page_id );

/**
 * Page layout options.
 *
 * These are filterable so you can control the template later from:
 * - functions.php
 * - inc/helpers/template-functions.php
 * - customizer
 * - theme options panel
 */
$rx_show_breadcrumbs      = apply_filters( 'rx_theme_full_width_show_breadcrumbs', true, $rx_page_id );
$rx_show_page_title       = apply_filters( 'rx_theme_full_width_show_title', true, $rx_page_id );
$rx_show_featured_image   = apply_filters( 'rx_theme_full_width_show_featured_image', true, $rx_page_id );
$rx_show_last_updated     = apply_filters( 'rx_theme_full_width_show_last_updated', true, $rx_page_id );
$rx_show_author_box       = apply_filters( 'rx_theme_full_width_show_author_box', false, $rx_page_id );
$rx_show_page_navigation  = apply_filters( 'rx_theme_full_width_show_page_navigation', true, $rx_page_id );
$rx_show_comments         = apply_filters( 'rx_theme_full_width_show_comments', true, $rx_page_id );
$rx_show_after_content_cta = apply_filters( 'rx_theme_full_width_show_after_content_cta', false, $rx_page_id );

/**
 * Schema values.
 */
$rx_schema_type = apply_filters( 'rx_theme_full_width_schema_type', 'WebPage', $rx_page_id );

?>

<main
	id="primary"
	class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $rx_wrapper_classes ) ) ); ?>"
	role="main"
	itemscope
	itemtype="https://schema.org/<?php echo esc_attr( $rx_schema_type ); ?>"
>

	<?php
	/**
	 * Hook before full-width page content.
	 *
	 * Useful for:
	 * - ad banner
	 * - top notice
	 * - emergency medical disclaimer
	 * - custom hero section
	 */
	do_action( 'rx_theme_before_full_width_template', $rx_page_id );
	?>

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

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

			$rx_post_id        = get_the_ID();
			$rx_author_id      = get_post_field( 'post_author', $rx_post_id );
			$rx_modified_time  = get_the_modified_time( 'c', $rx_post_id );
			$rx_published_time = get_the_time( 'c', $rx_post_id );
			?>

			<article
				id="post-<?php the_ID(); ?>"
				<?php post_class( 'rx-full-width-article rx-page-article' ); ?>
				itemprop="mainEntity"
				itemscope
				itemtype="https://schema.org/CreativeWork"
			>

				<?php
				/**
				 * Hook before article header.
				 */
				do_action( 'rx_theme_before_full_width_article_header', $rx_post_id );
				?>

				<header class="rx-full-width-header rx-entry-header">

					<?php
					/**
					 * Breadcrumb area.
					 *
					 * Recommended:
					 * Put your breadcrumb function in:
					 * inc/helpers/breadcrumbs.php
					 */
					if ( true === $rx_show_breadcrumbs ) :
						?>
						<nav
							class="rx-breadcrumb-wrap"
							aria-label="<?php echo esc_attr__( 'Breadcrumb', 'rx-theme' ); ?>"
						>
							<?php
							if ( function_exists( 'rx_theme_breadcrumbs' ) ) {
								rx_theme_breadcrumbs();
							} elseif ( function_exists( 'yoast_breadcrumb' ) ) {
								yoast_breadcrumb( '<p id="breadcrumbs" class="rx-yoast-breadcrumbs">', '</p>' );
							} elseif ( function_exists( 'rank_math_the_breadcrumbs' ) ) {
								rank_math_the_breadcrumbs();
							}
							?>
						</nav>
					<?php endif; ?>

					<?php
					/**
					 * Page title.
					 */
					if ( true === $rx_show_page_title ) :
						?>
						<h1 class="rx-entry-title rx-full-width-title" itemprop="headline">
							<?php the_title(); ?>
						</h1>
					<?php endif; ?>

					<?php
					/**
					 * Optional excerpt / subtitle.
					 */
					if ( has_excerpt() ) :
						?>
						<div class="rx-entry-excerpt rx-full-width-excerpt" itemprop="description">
							<?php echo wp_kses_post( wpautop( get_the_excerpt() ) ); ?>
						</div>
					<?php endif; ?>

					<?php
					/**
					 * Page meta.
					 */
					if ( true === $rx_show_last_updated ) :
						?>
						<div class="rx-entry-meta rx-full-width-meta" aria-label="<?php echo esc_attr__( 'Page information', 'rx-theme' ); ?>">

							<time
								class="rx-published-date"
								datetime="<?php echo esc_attr( $rx_published_time ); ?>"
								itemprop="datePublished"
							>
								<?php
								printf(
									/* translators: %s: published date */
									esc_html__( 'Published: %s', 'rx-theme' ),
									esc_html( get_the_date() )
								);
								?>
							</time>

							<span class="rx-meta-separator" aria-hidden="true"> | </span>

							<time
								class="rx-updated-date"
								datetime="<?php echo esc_attr( $rx_modified_time ); ?>"
								itemprop="dateModified"
							>
								<?php
								printf(
									/* translators: %s: modified date */
									esc_html__( 'Updated: %s', 'rx-theme' ),
									esc_html( get_the_modified_date() )
								);
								?>
							</time>

						</div>
					<?php endif; ?>

				</header>

				<?php
				/**
				 * Hook after article header.
				 */
				do_action( 'rx_theme_after_full_width_article_header', $rx_post_id );
				?>

				<?php
				/**
				 * Featured image.
				 */
				if ( true === $rx_show_featured_image && has_post_thumbnail() ) :
					?>
					<figure class="rx-featured-image rx-full-width-featured-image" itemprop="image">
						<?php
						the_post_thumbnail(
							'full',
							array(
								'class'    => 'rx-featured-img',
								'loading'  => 'eager',
								'decoding' => 'async',
								'alt'      => esc_attr( get_the_title() ),
							)
						);

						$rx_thumbnail_caption = get_the_post_thumbnail_caption();

						if ( ! empty( $rx_thumbnail_caption ) ) :
							?>
							<figcaption class="rx-featured-image-caption">
								<?php echo wp_kses_post( $rx_thumbnail_caption ); ?>
							</figcaption>
						<?php endif; ?>
					</figure>
				<?php endif; ?>

				<?php
				/**
				 * Hook before main content.
				 */
				do_action( 'rx_theme_before_full_width_content', $rx_post_id );
				?>

				<div class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $rx_content_classes ) ) ); ?>">

					<div class="rx-entry-content rx-full-width-entry-content" itemprop="text">

						<?php
						/**
						 * Main page content.
						 */
						the_content();

						/**
						 * Pagination for multi-page WordPress content.
						 */
						wp_link_pages(
							array(
								'before'      => '<nav class="rx-page-links" aria-label="' . esc_attr__( 'Page navigation', 'rx-theme' ) . '"><span class="rx-page-links-title">' . esc_html__( 'Pages:', 'rx-theme' ) . '</span>',
								'after'       => '</nav>',
								'link_before' => '<span class="rx-page-link">',
								'link_after'  => '</span>',
							)
						);
						?>

					</div>

				</div>

				<?php
				/**
				 * Optional after-content CTA.
				 *
				 * You can enable by filter:
				 *
				 * add_filter( 'rx_theme_full_width_show_after_content_cta', '__return_true' );
				 */
				if ( true === $rx_show_after_content_cta ) :
					?>
					<section class="rx-after-content-cta" aria-label="<?php echo esc_attr__( 'After content call to action', 'rx-theme' ); ?>">
						<div class="rx-after-content-cta-inner">
							<h2 class="rx-after-content-cta-title">
								<?php echo esc_html__( 'Need medical guidance?', 'rx-theme' ); ?>
							</h2>

							<p class="rx-after-content-cta-text">
								<?php echo esc_html__( 'This page is for educational purposes only. Please consult a qualified doctor for personal medical advice.', 'rx-theme' ); ?>
							</p>
						</div>
					</section>
				<?php endif; ?>

				<?php
				/**
				 * Author box.
				 */
				if ( true === $rx_show_author_box ) :
					?>
					<section class="rx-author-box" aria-label="<?php echo esc_attr__( 'Author information', 'rx-theme' ); ?>">
						<div class="rx-author-box-inner">

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

							<div class="rx-author-content">
								<h2 class="rx-author-title">
									<?php echo esc_html__( 'Written by', 'rx-theme' ); ?>
									<span itemprop="author">
										<?php echo esc_html( get_the_author_meta( 'display_name', $rx_author_id ) ); ?>
									</span>
								</h2>

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

							</div>

						</div>
					</section>
				<?php endif; ?>

				<?php
				/**
				 * Page navigation.
				 */
				if ( true === $rx_show_page_navigation ) :
					?>
					<nav class="rx-single-page-navigation" aria-label="<?php echo esc_attr__( 'Page navigation', 'rx-theme' ); ?>">
						<div class="rx-single-page-navigation-inner">

							<div class="rx-nav-previous">
								<?php previous_post_link( '%link', esc_html__( 'Previous: %title', 'rx-theme' ) ); ?>
							</div>

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

						</div>
					</nav>
				<?php endif; ?>

				<?php
				/**
				 * Hook after content.
				 */
				do_action( 'rx_theme_after_full_width_content', $rx_post_id );
				?>

				<?php
				/**
				 * Comments.
				 */
				if ( true === $rx_show_comments && comments_open() || get_comments_number() ) :
					?>
					<section class="rx-comments-area-wrap">
						<?php comments_template(); ?>
					</section>
				<?php endif; ?>

				<?php
				/**
				 * Hidden schema meta.
				 */
				?>
				<meta itemprop="mainEntityOfPage" content="<?php echo esc_url( get_permalink( $rx_post_id ) ); ?>">
				<meta itemprop="url" content="<?php echo esc_url( get_permalink( $rx_post_id ) ); ?>">
				<meta itemprop="datePublished" content="<?php echo esc_attr( $rx_published_time ); ?>">
				<meta itemprop="dateModified" content="<?php echo esc_attr( $rx_modified_time ); ?>">

				<?php
				/**
				 * Hook before article close.
				 */
				do_action( 'rx_theme_before_full_width_article_close', $rx_post_id );
				?>

			</article>

			<?php
			/**
			 * Hook after article.
			 */
			do_action( 'rx_theme_after_full_width_article', $rx_post_id );

		endwhile;
		?>

	<?php else : ?>

		<section class="rx-no-content rx-full-width-no-content">
			<header class="rx-no-content-header">
				<h1 class="rx-no-content-title">
					<?php echo esc_html__( 'Nothing Found', 'rx-theme' ); ?>
				</h1>
			</header>

			<div class="rx-no-content-body">
				<p>
					<?php echo esc_html__( 'Sorry, no content was found for this page.', 'rx-theme' ); ?>
				</p>

				<?php get_search_form(); ?>
			</div>
		</section>

	<?php endif; ?>

	<?php
	/**
	 * Hook after full-width page content.
	 *
	 * Useful for:
	 * - related pages
	 * - newsletter
	 * - medical disclaimer
	 * - structured data output
	 */
	do_action( 'rx_theme_after_full_width_template', $rx_page_id );
	?>

</main>

<?php
get_footer();

Important small fix

This line in the code:

if ( true === $rx_show_comments && comments_open() || get_comments_number() ) :

works, but for cleaner advanced-level code, I recommend this safer version:

if ( true === $rx_show_comments && ( comments_open() || get_comments_number() ) ) :

So replace this part:

if ( true === $rx_show_comments && comments_open() || get_comments_number() ) :

with:

if ( true === $rx_show_comments && ( comments_open() || get_comments_number() ) ) :

Best matching CSS file

Create this CSS file:

assets/css/templates/template-full-width.css

Add starter CSS:

/**
 * RX Theme Full Width Template
 */

.rx-full-width-template {
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
}

.rx-full-width-article {
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
}

.rx-full-width-header {
	width: min(100% - 32px, 1200px);
	margin-inline: auto;
	padding-block: clamp(32px, 5vw, 72px);
}

.rx-full-width-title {
	margin: 0;
	font-size: clamp(2rem, 5vw, 4rem);
	line-height: 1.1;
}

.rx-full-width-excerpt {
	max-width: 850px;
	margin-top: 20px;
	font-size: clamp(1rem, 2vw, 1.25rem);
	line-height: 1.7;
}

.rx-full-width-meta {
	margin-top: 18px;
	font-size: 0.9375rem;
	opacity: 0.8;
}

.rx-full-width-featured-image {
	width: min(100% - 32px, 1400px);
	margin: 0 auto 40px;
}

.rx-featured-img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--rx-radius-lg, 16px);
}

.rx-featured-image-caption {
	margin-top: 10px;
	font-size: 0.875rem;
	text-align: center;
	opacity: 0.75;
}

.rx-full-width-content {
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
}

.rx-full-width-entry-content {
	width: min(100% - 32px, 1200px);
	margin-inline: auto;
}

.rx-full-width-entry-content > * {
	max-width: 850px;
	margin-left: auto;
	margin-right: auto;
}

.rx-full-width-entry-content > .alignwide {
	max-width: 1200px;
}

.rx-full-width-entry-content > .alignfull {
	max-width: none;
	width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
}

.rx-after-content-cta {
	width: min(100% - 32px, 1000px);
	margin: 56px auto;
	padding: clamp(24px, 4vw, 48px);
	border-radius: var(--rx-radius-lg, 16px);
	background: var(--rx-color-surface, #f7f9fc);
}

.rx-author-box {
	width: min(100% - 32px, 900px);
	margin: 56px auto;
	padding: 24px;
	border: 1px solid var(--rx-color-border, #e5e7eb);
	border-radius: var(--rx-radius-lg, 16px);
}

.rx-author-box-inner {
	display: flex;
	gap: 20px;
	align-items: flex-start;
}

.rx-single-page-navigation {
	width: min(100% - 32px, 900px);
	margin: 56px auto;
}

.rx-single-page-navigation-inner {
	display: flex;
	justify-content: space-between;
	gap: 24px;
}

.rx-comments-area-wrap {
	width: min(100% - 32px, 900px);
	margin: 56px auto;
}

@media (max-width: 768px) {
	.rx-author-box-inner,
	.rx-single-page-navigation-inner {
		flex-direction: column;
	}
}

Enqueue this CSS only for this template

In your functions.php or better in:

inc/core/enqueue.php

add this:

<?php
/**
 * Enqueue RX full-width template CSS.
 */
function rx_theme_enqueue_full_width_template_style() {

	if ( is_page_template( 'templates/template-full-width.php' ) ) {
		wp_enqueue_style(
			'rx-template-full-width',
			get_template_directory_uri() . '/assets/css/templates/template-full-width.css',
			array(),
			wp_get_theme()->get( 'Version' )
		);
	}
}
add_action( 'wp_enqueue_scripts', 'rx_theme_enqueue_full_width_template_style' );

How to use it in WordPress

Go to:

WordPress Dashboard → Pages → Add New / Edit Page → Template → RX Full Width

Then update the page.

This template is advanced but still safe because it does not overload the page template with plugin-like jobs. The best RX Theme structure is: template file controls layout, functions.php/inc files control logic, and CSS files control design.

Friend, the best and most WordPress-standard location is:

rx-theme/templates/template-full-width.php

Use this one.

Best choice

rx-theme/
├── templates/
│   └── template-full-width.php

Why this is best:

WordPress page templates are usually placed in the theme root or a clear templates/ folder. This location is easy for WordPress, easy for you, and easy for future developers to understand.

Not best for page template

rx-theme/inc/templates/template-full-width.php

I do not recommend this for selectable WordPress page templates.

The inc/ folder should be used for PHP logic files, helper functions, classes, setup files, hooks, and reusable backend code.

Example:

rx-theme/
├── inc/
│   ├── core/
│   │   ├── theme-setup.php
│   │   ├── enqueue.php
│   │   └── menus.php
│   ├── helpers/
│   │   ├── template-functions.php
│   │   └── breadcrumbs.php

Final recommended RX Theme structure

rx-theme/
├── templates/
│   ├── template-full-width.php
│   ├── template-sidebar-left.php
│   ├── template-sidebar-right.php
│   ├── template-landing.php
│   └── template-medical-article.php
│
├── template-parts/
│   ├── content/
│   │   ├── content-page.php
│   │   ├── content-single.php
│   │   └── content-archive.php
│   ├── header/
│   ├── footer/
│   └── components/
│
├── inc/
│   ├── core/
│   ├── helpers/
│   ├── customizer/
│   └── classes/

My advice

Use:

templates/template-full-width.php

And use inc/ only for helping logic.

For example, your template file can call helper functions from:

inc/helpers/template-functions.php
inc/helpers/breadcrumbs.php

So the clean rule is:

templates/      = page layout files
template-parts/ = reusable visible parts
inc/            = PHP logic and functions
assets/         = CSS, JS, images, fonts

This is the most professional structure for RX Theme.

Leave a Reply

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