How can i share codes on my blog?

I’d suggest using Syntax Highlighter Evolved. It’s by Viper007Bond. You can use it like this: [sourcecode lang=”php”] <?php echo ‘Hello World!’; ?> [/sourcecode] Or even like this: [php] <?php echo ‘Hello World!’; ?> [/php] A screenshot: EDIT An example of how you could do the backticks method that SE uses: function wpse13653_content( $content ){ return … Read more

Replacement for gallery_shortcode function not taking all attributes

<?php function modified_post_gallery( $blank = NULL, $attr ) { echo ‘<pre>’; print_r( $attr ); echo ‘</pre>’; } add_filter( ‘post_gallery’, ‘modified_post_gallery’, 10, 2); ?> In media.php it shows the filter like this: // Allow plugins/themes to override the default gallery template. $output = apply_filters(‘post_gallery’, ”, $attr); Its passing two variables not one and $attr is on … Read more

Insert PHP code via shortcode?

$current_user isn’t declared in the scope of that function. You’d want to modify the code to be more like this: function get_form($atts) { $current_user = wp_get_current_user(); return ‘<form method=”post” action=””> <input type=”input” name=”myinput” value=””></input> <input type=”hidden” name=”myvar” value=”‘ . $current_user->ID . ‘”> </form>’; } add_shortcode(‘myshortcode’, ‘get_form’);

do_shortcode() in twentyeleven theme

It looks like twenty ten displays the excerpt on category archives. If you’re using manual excerpts, this is an easy fix. Just add this line of code to your theme’s functions.php file. It tells wordpress to run the excerpt through the do_shortcode function/filter. add_filter( ‘the_excerpt’, ‘do_shortcode’ ); If you’re not using manual excerpts, we have … Read more

Using Variables in Shortcodes

Simply don’t call return more than once. Just add your output to a variable: $some_variable_name=”mention the = at the beginning of this line”; $some_variable_name .= ‘Take a look at the .Period before the = in this line’; $some_variable_name .= ‘then add more lines always with the period’; // at the end of your shortcode function: … Read more