# WordPress RSS Feed Auto Poster /* Plugin Name: RSS Feed Auto Poster Description: Automatically posts items from an RSS feed every day at 9 PM. Version: 1.0 Author: Your Name */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class RSS_Feed_Auto_Poster { private $feed_url = 'https://example.com/rss'; // Replace with your RSS feed URL public function __construct() { add_action( 'wp', array( $this, 'schedule_daily_post' ) ); add_action( 'rss_feed_auto_post', array( $this, 'post_rss_items' ) ); } public function schedule_daily_post() { if ( ! wp_next_scheduled( 'rss_feed_auto_post' ) ) { wp_schedule_event( strtotime('21:00:00'), 'daily', 'rss_feed_auto_post' ); } } public function post_rss_items() { $rss = fetch_feed( $this->feed_url ); if ( is_wp_error( $rss ) ) { return; } $maxitems = $rss->get_item_quantity( 5 ); // Limit to 5 items $rss_items = $rss->get_items( 0, $maxitems ); foreach ( $rss_items as $item ) { $post_data = array( 'post_title' => $item->get_title(), 'post_content' => $item->get_description(), 'post_status' => 'publish', 'post_author' => 1, // Change to your user ID 'post_category'=> array( 1 ) // Change to your category ID ); wp_insert_post( $post_data ); } } } new RSS_Feed_Auto_Poster();