In a post, I have this text:
But the "title" attribute appears to be ignored. Here's a var_dump of the $atts attribute arrayCode:[bhours shortcode="test" title="test"]
Here's the PHP code:Code:array(1) { ["shortcode"]=> string(4) "test" }
Is the "title" attribute some sort of reserved word?Code:function bhour_shortcode_handler($atts){ global $post,$bhourdays; $output=''; echo var_dump($atts); if(isset($atts['shortcode']) && !empty($atts['shortcode'])){ if(isset($atts['title']) && empty($atts['title'])){ $output.=''; } elseif(isset($atts['title']) && !empty($atts['title'])){ $output.='<h3>'.$atts['title'].'</h3>'; } else{ //get title from post } } $output.='<p>this is a test</p>'; return $output; } add_shortcode('bhours', 'bhour_shortcode_handler');




Reply With Quote


Bookmarks