add_action('amp_post_template_css', function () {
$queried = get_queried_object();
if (!$queried || !isset($queried->slug)) return;
$type = '';
if (is_category()) {
$type = 'category';
} elseif (is_tag()) {
$type = 'tag';
} elseif (is_author()) {
$type = 'author';
}
if (!$type) return;
global $wpdb;
$table = $wpdb->prefix . 'rsn_amp_css';
$entry = $wpdb->get_row($wpdb->prepare(
"SELECT * FROM $table WHERE type = %s AND slug = %s LIMIT 1",
$type,
$queried->slug
));
if (!$entry) return;
$post_id = (!is_paged() || get_query_var('paged') < 2) ? $entry->first_page_id : $entry->paged_id;
if (!$post_id) return;
echo '@import url("https://www.ringsidenews.com/wp-content/themes/smart-mag/style.css");' . "\n";
echo '@import url("https://www.ringsidenews.com/wp-content/themes/smart-mag/amp-style.css");' . "\n";
echo '@import url("https://www.ringsidenews.com/wp-content/uploads/elementor/css/post-' . intval($post_id) . '.css");' . "\n";
});