Function not receiving string from shortcode

It appears like you can not use upper case like that in a shortcode. Instead of videoUrl, use video-url: function get_youtube_thumb_url_func( $atts ) { $atts = shortcode_atts( array( ‘video-url’ => ‘urlHere’, ), $atts, ‘youtube-thumb-url’ ); return $atts[‘video-url’]; } add_shortcode( ‘youtube-thumb-url’, ‘get_youtube_thumb_url_func’ ); And your shortcode: [youtube-thumb-url video-url=”test”] This is the final function that I tested … Read more

Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop

That error means you’re attempting to address a string or null as if it were an array. Perhaps it’s returning fewer than 5 matches, in which case $array[0][4] would be unset. Here’s your problem: function thing($content) { preg_match_all(“/(<h[^>]*>.*?<\/h2>\n*<p>.*?<\/p>)/”, $content, $array); $i = 1; $limit = count($array[0]); $array = $array[0][4]; // you’ve overwritten $array with what … Read more

restrict uploaded image size and fixed image display size

Add this code to your theme’s functions.php file, and it will limit image dimentions add_filter(‘wp_handle_upload_prefilter’,’tc_handle_upload_prefilter’); function tc_handle_upload_prefilter($file) { $img=getimagesize($file[‘tmp_name’]); $minimum = array(‘width’ => ‘600’, ‘height’ => ‘900’); $width= $img[0]; $height =$img[1]; if ($width < $minimum[‘width’] ) return array(“error”=>”Image dimensions are too small. Minimum width is {$minimum[‘width’]}px. Uploaded image width is $width px”); elseif ($height < … Read more