function format_rss_post_content($post_content) {
// Load the post content into DOMDocument
$dom = new DOMDocument();
@$dom->loadHTML($post_content); // Suppress warnings for malformed HTML
$xpath = new DOMXPath($dom);
// Extract the first image and place it at the top of the post
$first_image = $xpath->query("//img")->item(0);
$first_image_html = '';
if ($first_image) {
$first_image_html = $dom->saveHTML($first_image);
}
// Extract the title
$title = $xpath->query("//title")->item(0);
$title_html = '';
if ($title) {
$title_text = $title->nodeValue;
$title_html = "<h1 style='text-align:center; font-weight:bold;'>$title_text</h1>";
}
// Extract start and end dates (assuming specific HTML tags or classes)
$start_date = $xpath->query("//span[@class='start-date']")->item(0);
$start_date_html = '';
if ($start_date) {
$start_date_text = $start_date->nodeValue;
$start_date_html = "<strong>Starts:</strong> $start_date_text</p>";
}
$end_date = $xpath->query("//span[@class='end-date']")->item(0);
$end_date_html = '';
if ($end_date) {
$end_date_text = $end_date->nodeValue;
$end_date_html = "<p><strong>Ends:</strong> $end_date_text</p>";
}
// Extract the first few sentences for the introduction
$paragraphs = $xpath->query("//p");
$intro_html = '';
if ($paragraphs->length > 0) {
$intro_html = "<p>" . substr($paragraphs->item(0)->nodeValue, 0, 200) . "...</p>"; // Extract the first 200 characters
}
// Extract main content
$main_content_html = '';
foreach ($paragraphs as $paragraph) {
$main_content_html .= $dom->saveHTML($paragraph);
}
$main_content_html = "<div>$main_content_html</div>";
// Extract specific Pokémon image and caption if mentioned
$pokemon_image = $xpath->query("//img[contains(@alt, 'Pokémon')]")->item(0);
$pokemon_image_html = '';
if ($pokemon_image) {
$pokemon_image_caption = $pokemon_image->getAttribute('alt');
$pokemon_image_html = $dom->saveHTML($pokemon_image);
$pokemon_image_html .= "<p style='text-align:center;'>$pokemon_image_caption</p>";
}
// Combine all extracted parts into the final HTML structure
$formatted_content = "
$first_image_html
$title_html
<section>
$start_date_html
$end_date_html
</section>
$intro_html
$main_content_html
$pokemon_image_html
";
return $formatted_content;
}
// Use this function in your theme/plugin where RSS feed content is processed
$post_content = ‘
Paldean Blaze Breed Tauros
Blaze Breed Paldean Tauros is a Fighting and Fire type Pokémon from the Paldea region. It is only available in the Eastern Hemisphere. Blaze Breed Paldean Tauros is weak to Ground, Psychic, , and Water type Pokémon, giving it quite an array of available counters.
Blaze Breed Paldean Tauros can have the following CP values when caught in the post-raid capture encounter:
- 1546 CP – 1621 CP in normal weather conditions
- 1932 CP – 2026 CP in Cloudy and Sunny weather for weather boosts.
Blaze Breed Paldean Tauros can be soloed by high level prepared trainers, but those without ideal counters may want to bring a friend.
Best Blaze Breed Paldean Tauros Counters
The strongest Pokémon to use against Blaze Breed Paldean Tauros are:
Blaze Breed Paldean Tauros Overview
The shiny is a more subtle version, with the grey and black parts swapping, so watch for those sparkles!
All the best, trainers!
‘; // Replace this with actual content from RSS feed
echo format_rss_post_content($post_content);
