Using a variable in name of dynamically-called helper function
get_option(‘show_season_title_’ . $k); I think, I don’t have a way to test that right now but it should work.
get_option(‘show_season_title_’ . $k); I think, I don’t have a way to test that right now but it should work.
I’m getting invalid taxonomy in init action
Maybe you should simply use the wp_trim_words function to achieve what you want. Simply pass the get_the_excerpt value in it. <?php $trimmed = wp_trim_words( $text, $num_words = 55, $more = null ); ?>
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
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
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
Take a look at WordPress’ Post Status Transitions hooks: https://codex.wordpress.org/Post_Status_Transitions If you’ve added proper debugging (so that you die at the top of your hooked function) it sounds like you’re not hooking into the right action. Since you’re adding some meta and checking for it to see if you should run again, you could hook … Read more
If all you want to do is count how many times the shortcode exists in the content then you can use substr_count on the original content before it’s parsed to output shortcodes like this: $count = substr_count( get_the_content(), ‘[col]’ ); But nesting shortcodes is most likely the best solution unless you know exactly the type … Read more
Load scripts into an AJAX div
Load scripts into an AJAX div