I had chat gpt create a piece of code that i uploaded as a plug in into wordpress. the goal is to have my site host an embedded version of my sub. the code seems straight foreward, but when i call the short code, i get a message that it cannot connect to reddit.com . is there some sort of permissions i am not obtaining from reddit or is there an error in the code?
​
<?php
/*
Plugin Name: Subreddit Embed
Description: Embeds a subreddit using a link
Version: 1.0
Author: Your Name
*/
// Define the shortcode to use in the post editor
add_shortcode( ‘subreddit’, ’embed_subreddit’ );
// Function that will embed the subreddit
function embed_subreddit( $atts ) {
// Get the link from the shortcode attributes
$link = $atts[‘link’];
// Extract the subreddit name from the link
$subreddit = preg_replace(‘/https?:\/\/(www\.)?reddit.com\/r\//’, ”, $link);
// Build the embed HTML
$html = ‘<iframe src=”https://www.reddit.com/r/’.$subreddit.’/embed” width=”100%” height=”600″ frameborder=”0″></iframe>’;
// Return the embed HTML
return $html;
}

This almost decade old comment summarizes what’s up: