Custom Shortcode Broken in WordPress 3.1

You didn’t add the shortcode via the shortcode API. WordPress only recognizes shortcodes if they are added with: add_shortcode( ‘yourshortcode’, ‘yourshortcodefunc’ ); I personally would not use preg_replace for this because it is more of a hit and miss. You should follow the official guidelines off the WordPress Codex. Recommended code structure for shortcodes is: … Read more

Get URL from shortcode tag

There’s no need to use regex for this. WordPress has a Shortcode API to do this work for you. That codex page includes one of my favorite codex code snippets: function bartag_func( $atts ) { extract( shortcode_atts( array( ‘foo’ => ‘something’, ‘bar’ => ‘something else’, ), $atts ) ); … Right at the start of … Read more

Shortcodes: closing shortcode not being processed

The reason echo do_shortcode(“[/expand]”); is not working is because [/expand] is not a valid shortcode on it’s own. The combination of [expand] and [/expand] is valid so echo do_shortcode(“[expand] some content [/expand]”); should work as intended. If you want to use this way of seting things up <?php echo do_shortcode(“[expand]”); ?> content <?php echo do_shortcode(“[/expand]”); … Read more

check if the user is owner of current page

Per the Codex, is_author() checks to see if you’re on an Author Archive page (ie, a page listing all the posts/pages/etc that a given user has authored). If you’re on any other type of page, is_author() will return false. What you’re looking for sounds more along these lines: if ( in_the_loop() ) { get_currentuserinfo(); print … Read more