Can I use theme options to change two things at once?

Nothing prevents you from retrieving your option in several places. You can do several get_option() calls or create global variable and assign your value to it once. It is hard to come up with specific example without knowing what exactly you store in option and which classes you want to generate for your markup. Update … Read more

Duplicate and alter sidebar for Twenty Eleven

the layout is controlled by the .singular css class, which in turn is generated in functions.php depending on the template. in your child theme of Twenty Eleven (if you don’t have a child theme, create one first) add this code to functions.php: add_filter(‘body_class’, ‘wpse_28044_adjust_body_class’, 20, 2); function wpse_28044_adjust_body_class($wp_classes, $extra_classes) { if( is_page_template(‘submenu-page.php’) ) : // … Read more

How to load different css file depending on language

function load_my_styles() { wp_register_style( ‘my-en-style1’, plugins_url( ‘en-style1.css’, __FILE__ ) ); wp_register_style( ‘my-en-style2’, plugins_url( ‘en-style2.css’, __FILE__ ) ); wp_register_style( ‘my-ja-style1’, plugins_url( ‘ja-style1.css’, __FILE__ ) ); wp_register_style( ‘my-ja-style2’, plugins_url( ‘ja-style2.css’, __FILE__ ) ); $lang = preg_match( ‘/^\/ja\//i’, $_SERVER[‘REQUEST_URI’] ) ? ‘ja’ : ‘en’; wp_enqueue_style( “my-{$lang}-style1” ); wp_enqueue_style( “my-{$lang}-style2” ); } add_action( ‘wp_enqueue_scripts’, ‘load_my_styles’ );

Custom Post type menu highlighted in the archive/post

You have it almost right. Try the following: function add_active_classes($classes = array(), $menu_item = false){ global $wp_query; if(in_array(‘current-menu-item’, $menu_item->classes)){ $classes[] = ‘current-menu-item’; } if ( $menu_item->title == ‘product’ && is_post_type_archive(‘product’) ) { $classes[] = ‘current-menu-item’; } if ( $menu_item->title== ‘product’ && is_singular(‘product’) ) { $classes[] = ‘current-menu-item’; } return $classes; } add_filter( ‘nav_menu_css_class’, ‘add_active_classes’, 10, … Read more

How extend shortcode default values for a plugin?

You can hijack the shortcode and use your own additional logic. Sample code, not tested: add_action( ‘after_setup_theme’, function() { // Replace the plugin shortcode handler with your own. add_shortcode( ‘standout-css3-button’, function( $atts, $content = NULL ) { // Let the plugin make the button and store the result. $button = scss3button( $atts, $content ); // … Read more

Limit function to specific post category

You should check for category posts to modify content. Specify category ID (integer), name or slug (string), or an array of these in in_category check. function my_image_tag( $html, $id , $alt, $title ) { if ( in_category( ‘1’ ) ) { $html = “<div class=”my-class”>” . $html . “</div>”; } return $html; } add_filter( ‘get_image_tag’, … Read more