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

Custom download page

Finally I solve the problem. Here the code bellow for download button. Put this code into your post loop it will show a download button. <form action=”<?php echo esc_url( home_url( ‘/your_redirected_page_slug’ ) ); ?>” method=”GET” id=”form1″> <?php global $post; //$post_slug=$post->post_name; ?> <input id=”myButton” type=”submit” name=”a” value=”Download” class=”single-download-button” /> <input type=”hidden” name=”appk” id=”mkval” value=”<?php echo get_the_ID(); … Read more

Hide disclaimer from summary excerpts

You could do something like this: /* Add disclaimer to top of POSTS that contain affiliate tag */ function tt_filter_the_content( $content ) { if (has_tag(‘affiliate’) && is_single()) $custom_content=”<hr><p><em>Disclosure: This post contains affiliate links and we may receive a referral fee (at no extra cost to you) if you sign up or purchase products or services … Read more