// Shortcode function function rss_feed_shortcode($atts) { // Extract shortcode attributes $atts = shortcode_atts(array( 'url' => '', // Default RSS feed URL 'count' => 4 // Default number of posts to display ), $atts); // Get the RSS feed URL $rss_url = $atts['url']; // Fetch the RSS feed $rss = fetch_feed($rss_url); if (!is_wp_error($rss)) { // Get the feed items $feed_items = $rss->get_items(); // Start building the output $output = ''; // Add title outside of the feed container $output .= '

خواندنی‌های ژورنال

'; $output .= '
'; // Counter for limiting the number of posts $counter = 0; foreach ($feed_items as $item) { // Limit the loop to the specified number of posts if ($counter >= $atts['count']) { break; } $title = esc_html($item->get_title()); $link = esc_url($item->get_permalink()); $description = strip_tags($item->get_description()); // Strip HTML tags from description // Extract the first 18 words of the description $words = preg_split("/[\s,]+/", $description); $description = implode(' ', array_slice($words, 0, 18)); // Add ellipsis if the description is truncated if (count($words) > 18) { $description .= '...'; } $thumbnail = ''; // Get the first image in the post content as thumbnail $content = $item->get_content(); preg_match('//i', $content, $matches); if (!empty($matches[1])) { $thumbnail = '' . $title . ''; } // Build the post HTML $output .= ''; $output .= '
'; if (!empty($thumbnail)) { $output .= '
' . $thumbnail . '
'; } $output .= '
'; $output .= '

' . $title . '

'; $output .= '

' . $description . '

'; $output .= '
'; // .rss-feed-content $output .= '
'; // .rss-feed-item $output .= '
'; // close anchor tag // Increment the counter $counter++; } $output .= '
'; // .rss-feed return $output; } else { return '

Error fetching RSS feed.

'; } } اورز | Ours | هامیا
دسته بندی محصولات
۱۷+

دیگر دسته بندی ها

براساس قیمت (تومان)
برند

نمایش 1 - 7 کالا از 7

اورز | Ours

مقایسه ( 0 مورد )