content-none.php

I’ll build this as a reusable content-none.php template part for your RX theme: safe escaping, search-specific suggestions, category/tag/archive context, optional search form, popular/recent posts fallback, sitemap-style links, and schema-friendly markup.

Below is an advanced, feature-rich inc/template-parts/content-none.php file for your RX Theme.
It is designed for cases like: no search results, empty category/tag/archive, empty blog, 404-style fallback inside loops, and helpful navigation for users.

Create this file:

mkdir -p inc/template-parts
touch inc/template-parts/content-none.php

Then paste this code inside:

<?php
/**
 * Template part for displaying a message when posts are not found.
 *
 * File: inc/template-parts/content-none.php
 *
 * Used when:
 * - No posts are found in search results.
 * - No posts exist in archive/category/tag pages.
 * - The site has no published posts yet.
 * - A loop returns empty results.
 *
 * @package RX_Theme
 */

defined( 'ABSPATH' ) || exit;

/**
 * ------------------------------------------------------------
 * Basic Context Detection
 * ------------------------------------------------------------
 */

$rx_is_search        = is_search();
$rx_is_home          = is_home();
$rx_is_front_page    = is_front_page();
$rx_is_archive       = is_archive();
$rx_is_category      = is_category();
$rx_is_tag           = is_tag();
$rx_is_author        = is_author();
$rx_is_date          = is_date();
$rx_is_post_type     = is_post_type_archive();
$rx_is_tax           = is_tax();
$rx_is_404           = is_404();

$rx_search_query_raw = get_search_query();
$rx_search_query     = trim( wp_strip_all_tags( $rx_search_query_raw ) );

$rx_site_name        = get_bloginfo( 'name' );
$rx_home_url         = home_url( '/' );
$rx_blog_url         = get_permalink( get_option( 'page_for_posts' ) );
$rx_blog_url         = $rx_blog_url ? $rx_blog_url : $rx_home_url;

$rx_current_url      = '';
if ( isset( $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'] ) ) {
	$rx_current_url = esc_url_raw(
		( is_ssl() ? 'https://' : 'http://' ) .
		wp_unslash( $_SERVER['HTTP_HOST'] ) .
		wp_unslash( $_SERVER['REQUEST_URI'] )
	);
}

/**
 * ------------------------------------------------------------
 * Customizer / Filter Friendly Options
 * ------------------------------------------------------------
 *
 * You can override these values from functions.php using filters.
 */

$rx_show_search_form = apply_filters( 'rx_content_none_show_search_form', true );
$rx_show_recent      = apply_filters( 'rx_content_none_show_recent_posts', true );
$rx_show_categories  = apply_filters( 'rx_content_none_show_categories', true );
$rx_show_tags        = apply_filters( 'rx_content_none_show_tags', true );
$rx_show_archives    = apply_filters( 'rx_content_none_show_archives', true );
$rx_show_pages       = apply_filters( 'rx_content_none_show_pages', true );
$rx_show_contact     = apply_filters( 'rx_content_none_show_contact_link', true );
$rx_show_admin_help  = apply_filters( 'rx_content_none_show_admin_help', current_user_can( 'publish_posts' ) );

$rx_recent_count     = absint( apply_filters( 'rx_content_none_recent_posts_count', 6 ) );
$rx_category_count   = absint( apply_filters( 'rx_content_none_categories_count', 8 ) );
$rx_tag_count        = absint( apply_filters( 'rx_content_none_tags_count', 12 ) );
$rx_page_count       = absint( apply_filters( 'rx_content_none_pages_count', 6 ) );

/**
 * ------------------------------------------------------------
 * Helper: Get Better Title
 * ------------------------------------------------------------
 */

if ( $rx_is_search ) {
	$rx_title = sprintf(
		/* translators: %s: Search query. */
		__( 'No results found for “%s”', 'rx-theme' ),
		$rx_search_query ? $rx_search_query : __( 'your search', 'rx-theme' )
	);
} elseif ( $rx_is_category ) {
	$rx_title = __( 'No posts found in this category', 'rx-theme' );
} elseif ( $rx_is_tag ) {
	$rx_title = __( 'No posts found for this tag', 'rx-theme' );
} elseif ( $rx_is_author ) {
	$rx_title = __( 'No posts found from this author', 'rx-theme' );
} elseif ( $rx_is_date ) {
	$rx_title = __( 'No posts found for this date archive', 'rx-theme' );
} elseif ( $rx_is_post_type ) {
	$rx_title = __( 'No items found in this section', 'rx-theme' );
} elseif ( $rx_is_tax ) {
	$rx_title = __( 'No posts found in this topic', 'rx-theme' );
} elseif ( $rx_is_home || $rx_is_front_page ) {
	$rx_title = __( 'No posts published yet', 'rx-theme' );
} else {
	$rx_title = __( 'Nothing found', 'rx-theme' );
}

$rx_title = apply_filters( 'rx_content_none_title', $rx_title );

/**
 * ------------------------------------------------------------
 * Helper: Get Better Description
 * ------------------------------------------------------------
 */

if ( $rx_is_search ) {
	$rx_description = __( 'We could not find any matching content. Try a different keyword, check your spelling, or explore the helpful links below.', 'rx-theme' );
} elseif ( $rx_is_category ) {
	$rx_description = __( 'This category does not have any published posts yet. You may explore other categories or return to the homepage.', 'rx-theme' );
} elseif ( $rx_is_tag ) {
	$rx_description = __( 'This tag does not have any published posts yet. You may browse recent articles or search for another topic.', 'rx-theme' );
} elseif ( $rx_is_author ) {
	$rx_description = __( 'This author has not published any posts yet. Please check back later or explore other articles.', 'rx-theme' );
} elseif ( $rx_is_date ) {
	$rx_description = __( 'There are no posts published for this date period. Try another archive month or browse recent articles.', 'rx-theme' );
} elseif ( $rx_is_home || $rx_is_front_page ) {
	$rx_description = __( 'It looks like no content has been published yet. Once posts are available, they will appear here.', 'rx-theme' );
} else {
	$rx_description = __( 'The content you are looking for is not available right now. You can search again or visit another section of the site.', 'rx-theme' );
}

$rx_description = apply_filters( 'rx_content_none_description', $rx_description );

/**
 * ------------------------------------------------------------
 * Search Suggestions
 * ------------------------------------------------------------
 */

$rx_search_suggestions = array();

if ( $rx_is_search && ! empty( $rx_search_query ) ) {
	$rx_words = preg_split( '/\s+/', $rx_search_query );

	if ( ! empty( $rx_words ) && is_array( $rx_words ) ) {
		foreach ( $rx_words as $rx_word ) {
			$rx_word = sanitize_text_field( $rx_word );

			if ( strlen( $rx_word ) >= 3 ) {
				$rx_search_suggestions[] = $rx_word;
			}
		}
	}
}

$rx_search_suggestions = array_unique( array_filter( $rx_search_suggestions ) );
$rx_search_suggestions = array_slice( $rx_search_suggestions, 0, 5 );

$rx_search_suggestions = apply_filters(
	'rx_content_none_search_suggestions',
	$rx_search_suggestions,
	$rx_search_query
);

/**
 * ------------------------------------------------------------
 * Recent Posts Query
 * ------------------------------------------------------------
 */

$rx_recent_posts = array();

if ( $rx_show_recent ) {
	$rx_recent_posts_query = new WP_Query(
		array(
			'post_type'              => 'post',
			'post_status'            => 'publish',
			'posts_per_page'         => $rx_recent_count,
			'ignore_sticky_posts'    => true,
			'no_found_rows'          => true,
			'update_post_meta_cache' => false,
			'update_post_term_cache' => true,
		)
	);

	if ( $rx_recent_posts_query->have_posts() ) {
		$rx_recent_posts = $rx_recent_posts_query->posts;
	}

	wp_reset_postdata();
}

/**
 * ------------------------------------------------------------
 * Popular Categories
 * ------------------------------------------------------------
 */

$rx_categories = array();

if ( $rx_show_categories ) {
	$rx_categories = get_categories(
		array(
			'orderby'    => 'count',
			'order'      => 'DESC',
			'number'     => $rx_category_count,
			'hide_empty' => true,
		)
	);
}

/**
 * ------------------------------------------------------------
 * Popular Tags
 * ------------------------------------------------------------
 */

$rx_tags = array();

if ( $rx_show_tags ) {
	$rx_tags = get_tags(
		array(
			'orderby'    => 'count',
			'order'      => 'DESC',
			'number'     => $rx_tag_count,
			'hide_empty' => true,
		)
	);
}

/**
 * ------------------------------------------------------------
 * Important Pages
 * ------------------------------------------------------------
 */

$rx_pages = array();

if ( $rx_show_pages ) {
	$rx_pages = get_pages(
		array(
			'sort_column' => 'menu_order,post_title',
			'sort_order'  => 'ASC',
			'number'      => $rx_page_count,
			'post_status' => 'publish',
		)
	);
}

/**
 * ------------------------------------------------------------
 * Contact Page Detection
 * ------------------------------------------------------------
 */

$rx_contact_page = null;

if ( $rx_show_contact ) {
	$rx_contact_candidates = get_pages(
		array(
			'post_status' => 'publish',
			'meta_key'    => '',
		)
	);

	if ( ! empty( $rx_contact_candidates ) ) {
		foreach ( $rx_contact_candidates as $rx_page ) {
			$rx_slug  = isset( $rx_page->post_name ) ? strtolower( $rx_page->post_name ) : '';
			$rx_title_for_contact = isset( $rx_page->post_title ) ? strtolower( $rx_page->post_title ) : '';

			if (
				false !== strpos( $rx_slug, 'contact' ) ||
				false !== strpos( $rx_title_for_contact, 'contact' )
			) {
				$rx_contact_page = $rx_page;
				break;
			}
		}
	}
}

/**
 * ------------------------------------------------------------
 * Admin New Post URL
 * ------------------------------------------------------------
 */

$rx_new_post_url = '';

if ( current_user_can( 'publish_posts' ) ) {
	$rx_new_post_url = admin_url( 'post-new.php' );
}

/**
 * ------------------------------------------------------------
 * Schema Data
 * ------------------------------------------------------------
 */

$rx_schema = array(
	'@context'    => 'https://schema.org',
	'@type'       => 'WebPage',
	'name'        => wp_strip_all_tags( $rx_title ),
	'description' => wp_strip_all_tags( $rx_description ),
	'url'         => $rx_current_url ? $rx_current_url : $rx_home_url,
	'isPartOf'    => array(
		'@type' => 'WebSite',
		'name'  => $rx_site_name,
		'url'   => $rx_home_url,
	),
);

if ( $rx_is_search ) {
	$rx_schema['@type']       = 'SearchResultsPage';
	$rx_schema['query']       = $rx_search_query;
	$rx_schema['mainEntity']  = array(
		'@type' => 'SearchAction',
		'query' => $rx_search_query,
	);
}

$rx_schema = apply_filters( 'rx_content_none_schema', $rx_schema );

?>

<section
	id="rx-content-none"
	class="rx-content-none no-results not-found"
	aria-labelledby="rx-content-none-title"
	itemscope
	itemtype="https://schema.org/WebPage"
>

	<script type="application/ld+json">
		<?php
		echo wp_json_encode(
			$rx_schema,
			JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT
		);
		?>
	</script>

	<header class="rx-content-none__header page-header">

		<div class="rx-content-none__icon" aria-hidden="true">
			<svg
				width="64"
				height="64"
				viewBox="0 0 24 24"
				fill="none"
				xmlns="http://www.w3.org/2000/svg"
				role="img"
				focusable="false"
			>
				<path d="M10.5 18C14.6421 18 18 14.6421 18 10.5C18 6.35786 14.6421 3 10.5 3C6.35786 3 3 6.35786 3 10.5C3 14.6421 6.35786 18 10.5 18Z" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
				<path d="M16 16L21 21" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
				<path d="M8.5 9H12.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
				<path d="M8.5 12H10.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
			</svg>
		</div>

		<h1 id="rx-content-none-title" class="rx-content-none__title page-title" itemprop="name">
			<?php echo esc_html( $rx_title ); ?>
		</h1>

		<p class="rx-content-none__description" itemprop="description">
			<?php echo esc_html( $rx_description ); ?>
		</p>

	</header>

	<div class="rx-content-none__body page-content">

		<?php if ( $rx_show_search_form ) : ?>
			<div class="rx-content-none__search rx-card">
				<h2 class="rx-content-none__section-title">
					<?php esc_html_e( 'Search again', 'rx-theme' ); ?>
				</h2>

				<p>
					<?php esc_html_e( 'Use a simple keyword or short phrase to find related articles.', 'rx-theme' ); ?>
				</p>

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

		<?php if ( $rx_is_search && ! empty( $rx_search_suggestions ) ) : ?>
			<div class="rx-content-none__suggestions rx-card">
				<h2 class="rx-content-none__section-title">
					<?php esc_html_e( 'Try these related searches', 'rx-theme' ); ?>
				</h2>

				<ul class="rx-content-none__suggestion-list">
					<?php foreach ( $rx_search_suggestions as $rx_suggestion ) : ?>
						<li>
							<a href="<?php echo esc_url( get_search_link( $rx_suggestion ) ); ?>">
								<?php echo esc_html( $rx_suggestion ); ?>
							</a>
						</li>
					<?php endforeach; ?>
				</ul>
			</div>
		<?php endif; ?>

		<div class="rx-content-none__actions rx-card">
			<h2 class="rx-content-none__section-title">
				<?php esc_html_e( 'Helpful links', 'rx-theme' ); ?>
			</h2>

			<div class="rx-content-none__button-group">

				<a class="rx-button rx-button--primary" href="<?php echo esc_url( $rx_home_url ); ?>">
					<?php esc_html_e( 'Go to homepage', 'rx-theme' ); ?>
				</a>

				<a class="rx-button rx-button--secondary" href="<?php echo esc_url( $rx_blog_url ); ?>">
					<?php esc_html_e( 'Browse blog', 'rx-theme' ); ?>
				</a>

				<?php if ( $rx_contact_page instanceof WP_Post ) : ?>
					<a class="rx-button rx-button--secondary" href="<?php echo esc_url( get_permalink( $rx_contact_page ) ); ?>">
						<?php esc_html_e( 'Contact us', 'rx-theme' ); ?>
					</a>
				<?php endif; ?>

				<?php if ( $rx_show_admin_help && ! empty( $rx_new_post_url ) ) : ?>
					<a class="rx-button rx-button--admin" href="<?php echo esc_url( $rx_new_post_url ); ?>">
						<?php esc_html_e( 'Create a new post', 'rx-theme' ); ?>
					</a>
				<?php endif; ?>

			</div>
		</div>

		<?php if ( ! empty( $rx_recent_posts ) ) : ?>
			<div class="rx-content-none__recent rx-card">
				<h2 class="rx-content-none__section-title">
					<?php esc_html_e( 'Recent articles', 'rx-theme' ); ?>
				</h2>

				<div class="rx-content-none__post-grid">
					<?php foreach ( $rx_recent_posts as $post ) : ?>
						<?php
						setup_postdata( $post );

						$rx_post_id        = get_the_ID();
						$rx_post_title     = get_the_title();
						$rx_post_permalink = get_permalink();
						$rx_post_date      = get_the_date();
						$rx_post_excerpt   = get_the_excerpt();
						?>

						<article class="rx-content-none__post-card" itemscope itemtype="https://schema.org/Article">

							<?php if ( has_post_thumbnail() ) : ?>
								<a class="rx-content-none__post-thumbnail" href="<?php echo esc_url( $rx_post_permalink ); ?>" aria-hidden="true" tabindex="-1">
									<?php
									the_post_thumbnail(
										'medium',
										array(
											'loading'  => 'lazy',
											'decoding' => 'async',
											'alt'      => the_title_attribute(
												array(
													'echo' => false,
												)
											),
										)
									);
									?>
								</a>
							<?php endif; ?>

							<div class="rx-content-none__post-content">
								<h3 class="rx-content-none__post-title" itemprop="headline">
									<a href="<?php echo esc_url( $rx_post_permalink ); ?>" itemprop="url">
										<?php echo esc_html( $rx_post_title ); ?>
									</a>
								</h3>

								<time class="rx-content-none__post-date" datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>">
									<?php echo esc_html( $rx_post_date ); ?>
								</time>

								<?php if ( ! empty( $rx_post_excerpt ) ) : ?>
									<p class="rx-content-none__post-excerpt" itemprop="description">
										<?php echo esc_html( wp_trim_words( $rx_post_excerpt, 18, '…' ) ); ?>
									</p>
								<?php endif; ?>
							</div>

						</article>

					<?php endforeach; ?>
					<?php wp_reset_postdata(); ?>
				</div>
			</div>
		<?php endif; ?>

		<?php if ( ! empty( $rx_categories ) ) : ?>
			<div class="rx-content-none__categories rx-card">
				<h2 class="rx-content-none__section-title">
					<?php esc_html_e( 'Popular categories', 'rx-theme' ); ?>
				</h2>

				<ul class="rx-content-none__term-list rx-content-none__category-list">
					<?php foreach ( $rx_categories as $rx_category ) : ?>
						<li>
							<a href="<?php echo esc_url( get_category_link( $rx_category->term_id ) ); ?>">
								<span><?php echo esc_html( $rx_category->name ); ?></span>
								<small>
									<?php
									printf(
										/* translators: %s: Number of posts. */
										esc_html( _n( '%s post', '%s posts', $rx_category->count, 'rx-theme' ) ),
										esc_html( number_format_i18n( $rx_category->count ) )
									);
									?>
								</small>
							</a>
						</li>
					<?php endforeach; ?>
				</ul>
			</div>
		<?php endif; ?>

		<?php if ( ! empty( $rx_tags ) ) : ?>
			<div class="rx-content-none__tags rx-card">
				<h2 class="rx-content-none__section-title">
					<?php esc_html_e( 'Popular tags', 'rx-theme' ); ?>
				</h2>

				<div class="rx-content-none__tag-cloud">
					<?php foreach ( $rx_tags as $rx_tag ) : ?>
						<a href="<?php echo esc_url( get_tag_link( $rx_tag->term_id ) ); ?>">
							<?php echo esc_html( $rx_tag->name ); ?>
						</a>
					<?php endforeach; ?>
				</div>
			</div>
		<?php endif; ?>

		<?php if ( $rx_show_archives ) : ?>
			<div class="rx-content-none__archives rx-card">
				<h2 class="rx-content-none__section-title">
					<?php esc_html_e( 'Monthly archives', 'rx-theme' ); ?>
				</h2>

				<ul class="rx-content-none__archive-list">
					<?php
					wp_get_archives(
						array(
							'type'            => 'monthly',
							'limit'           => 12,
							'show_post_count' => true,
							'echo'            => true,
						)
					);
					?>
				</ul>
			</div>
		<?php endif; ?>

		<?php if ( ! empty( $rx_pages ) ) : ?>
			<div class="rx-content-none__pages rx-card">
				<h2 class="rx-content-none__section-title">
					<?php esc_html_e( 'Useful pages', 'rx-theme' ); ?>
				</h2>

				<ul class="rx-content-none__page-list">
					<?php foreach ( $rx_pages as $rx_page ) : ?>
						<li>
							<a href="<?php echo esc_url( get_permalink( $rx_page ) ); ?>">
								<?php echo esc_html( get_the_title( $rx_page ) ); ?>
							</a>
						</li>
					<?php endforeach; ?>
				</ul>
			</div>
		<?php endif; ?>

		<?php if ( $rx_show_admin_help ) : ?>
			<div class="rx-content-none__admin rx-card rx-card--notice">
				<h2 class="rx-content-none__section-title">
					<?php esc_html_e( 'Admin notice', 'rx-theme' ); ?>
				</h2>

				<p>
					<?php esc_html_e( 'You are seeing this helper message because you can publish posts. If this page should contain content, create a post, publish content in this taxonomy, or check your query settings.', 'rx-theme' ); ?>
				</p>

				<ul>
					<li><?php esc_html_e( 'Check if posts are published, not draft or private.', 'rx-theme' ); ?></li>
					<li><?php esc_html_e( 'Check category, tag, author, date, or custom post type archive settings.', 'rx-theme' ); ?></li>
					<li><?php esc_html_e( 'Check custom WP_Query arguments if this appears inside a custom template.', 'rx-theme' ); ?></li>
					<li><?php esc_html_e( 'Check whether the post type supports public archive pages.', 'rx-theme' ); ?></li>
					<li><?php esc_html_e( 'Flush permalinks if archive URLs are not loading correctly.', 'rx-theme' ); ?></li>
				</ul>
			</div>
		<?php endif; ?>

	</div>

</section>

Add this CSS to your theme style.css or a separate file:

/*--------------------------------------------------------------
Content None Template
--------------------------------------------------------------*/

.rx-content-none {
	width: 100%;
	max-width: 1100px;
	margin: 0 auto;
	padding: 48px 20px;
	text-align: left;
}

.rx-content-none__header {
	text-align: center;
	margin-bottom: 32px;
}

.rx-content-none__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 96px;
	height: 96px;
	margin-bottom: 20px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.04);
	color: currentColor;
}

.rx-content-none__title {
	margin: 0 0 12px;
	font-size: clamp(28px, 4vw, 44px);
	line-height: 1.15;
	font-weight: 800;
	letter-spacing: -0.03em;
}

.rx-content-none__description {
	max-width: 720px;
	margin: 0 auto;
	font-size: 18px;
	line-height: 1.7;
	opacity: 0.82;
}

.rx-content-none__body {
	display: grid;
	gap: 24px;
}

.rx-card {
	padding: 24px;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 18px;
	background: #fff;
	box-shadow: 0 10px 35px rgba(0, 0, 0, 0.04);
}

.rx-card--notice {
	border-color: rgba(255, 193, 7, 0.45);
	background: rgba(255, 248, 225, 0.6);
}

.rx-content-none__section-title {
	margin: 0 0 14px;
	font-size: 22px;
	line-height: 1.3;
	font-weight: 700;
}

.rx-content-none__button-group {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.rx-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 18px;
	border-radius: 999px;
	font-weight: 700;
	text-decoration: none;
	transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.rx-button:hover,
.rx-button:focus {
	transform: translateY(-1px);
	text-decoration: none;
}

.rx-button--primary {
	background: #111827;
	color: #fff;
}

.rx-button--secondary {
	background: #f3f4f6;
	color: #111827;
}

.rx-button--admin {
	background: #2563eb;
	color: #fff;
}

.rx-content-none__suggestion-list,
.rx-content-none__term-list,
.rx-content-none__archive-list,
.rx-content-none__page-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.rx-content-none__suggestion-list {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.rx-content-none__suggestion-list a,
.rx-content-none__tag-cloud a {
	display: inline-flex;
	padding: 8px 14px;
	border-radius: 999px;
	background: #f3f4f6;
	color: #111827;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}

.rx-content-none__post-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 18px;
}

.rx-content-none__post-card {
	overflow: hidden;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 16px;
	background: #fff;
}

.rx-content-none__post-thumbnail {
	display: block;
	aspect-ratio: 16 / 9;
	background: #f3f4f6;
	overflow: hidden;
}

.rx-content-none__post-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.rx-content-none__post-content {
	padding: 16px;
}

.rx-content-none__post-title {
	margin: 0 0 8px;
	font-size: 18px;
	line-height: 1.35;
}

.rx-content-none__post-title a {
	color: inherit;
	text-decoration: none;
}

.rx-content-none__post-title a:hover,
.rx-content-none__post-title a:focus {
	text-decoration: underline;
}

.rx-content-none__post-date {
	display: block;
	margin-bottom: 10px;
	font-size: 13px;
	opacity: 0.7;
}

.rx-content-none__post-excerpt {
	margin: 0;
	font-size: 14px;
	line-height: 1.6;
	opacity: 0.82;
}

.rx-content-none__category-list {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

.rx-content-none__category-list a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	border-radius: 14px;
	background: #f9fafb;
	color: inherit;
	text-decoration: none;
}

.rx-content-none__category-list small {
	opacity: 0.65;
	white-space: nowrap;
}

.rx-content-none__tag-cloud {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.rx-content-none__archive-list,
.rx-content-none__page-list {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}

.rx-content-none__archive-list a,
.rx-content-none__page-list a {
	color: inherit;
	text-decoration: none;
}

.rx-content-none__archive-list a:hover,
.rx-content-none__page-list a:hover {
	text-decoration: underline;
}

.rx-content-none__admin ul {
	margin-bottom: 0;
	padding-left: 20px;
}

.rx-content-none__admin li {
	margin-bottom: 8px;
}

/* Search form compatibility */
.rx-content-none .search-form {
	display: flex;
	gap: 10px;
	max-width: 640px;
}

.rx-content-none .search-field {
	width: 100%;
	min-height: 46px;
	padding: 10px 14px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 12px;
}

.rx-content-none .search-submit {
	min-height: 46px;
	padding: 10px 18px;
	border: 0;
	border-radius: 12px;
	background: #111827;
	color: #fff;
	font-weight: 700;
	cursor: pointer;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
	.rx-card,
	.rx-content-none__post-card {
		background: #111827;
		border-color: rgba(255, 255, 255, 0.12);
	}

	.rx-content-none__icon {
		background: rgba(255, 255, 255, 0.08);
	}

	.rx-button--primary,
	.rx-content-none .search-submit {
		background: #f9fafb;
		color: #111827;
	}

	.rx-button--secondary,
	.rx-content-none__suggestion-list a,
	.rx-content-none__tag-cloud a,
	.rx-content-none__category-list a {
		background: rgba(255, 255, 255, 0.08);
		color: #f9fafb;
	}

	.rx-card--notice {
		background: rgba(146, 64, 14, 0.25);
		border-color: rgba(251, 191, 36, 0.35);
	}

	.rx-content-none .search-field {
		background: #0f172a;
		color: #fff;
		border-color: rgba(255, 255, 255, 0.18);
	}
}

/* Responsive */
@media (max-width: 900px) {
	.rx-content-none__post-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 640px) {
	.rx-content-none {
		padding: 36px 16px;
	}

	.rx-card {
		padding: 20px;
	}

	.rx-content-none__post-grid,
	.rx-content-none__category-list,
	.rx-content-none__archive-list,
	.rx-content-none__page-list {
		grid-template-columns: 1fr;
	}

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

	.rx-content-none__button-group {
		flex-direction: column;
	}

	.rx-button {
		width: 100%;
	}
}

Use it inside your theme templates like this:

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

Example inside index.php, archive.php, search.php, or custom loop:

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

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

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

	endwhile;
	?>

<?php else : ?>

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

<?php endif; ?>

You can control features from functions.php like this:

<?php
/**
 * RX Theme content-none controls.
 */

add_filter( 'rx_content_none_recent_posts_count', function () {
	return 8;
} );

add_filter( 'rx_content_none_categories_count', function () {
	return 10;
} );

add_filter( 'rx_content_none_tags_count', function () {
	return 16;
} );

add_filter( 'rx_content_none_show_archives', function () {
	return true;
} );

add_filter( 'rx_content_none_show_admin_help', function () {
	return current_user_can( 'manage_options' );
} );

This file is now much more than a simple “nothing found” message. It becomes a helpful recovery page for visitors, SEO-friendly with schema, safe with escaping, and useful for admins while building the RX theme.

Leave a Reply

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