Open external links in a new window

Yup can be done with javascript. var $j = jQuery.noConflict(); $j(document).ready(function() { //external attribute $j(“a:not([@href*=http://YOURSITE.com/])”).not(“[href^=#]”) .addClass(“external”) .attr({ target: “_blank” }); });

WP Super Cache separate cache for mobile

There are several ways to handle mobile devices and doing it inside of single theme is builky and hard to maintain (as for me at least). More commonly this seems to be accomplished with separate templates or separate mobile-specific theme. I don’t know about WP Super Cache specifics because I hadn’t used it extensively. Plugin … Read more

add_rewrite_rule and custom variable

Hi @westondeboer: Since you are saying your post type is ‘portfolio’ here’s what works on my WordPress v3.0.4 test site with a ‘portfolio’ custom post type defined. It replaces all the code you have: add_action(‘init’,’yoursite_init’); function yoursite_init() { global $wp,$wp_rewrite; $wp->add_query_var(‘view’); $wp_rewrite->add_rule(‘portfolio/([^/]+)/all’, ‘index.php?view=all&post_type=portfolio&name=$matches[1]’, ‘top’); // Once you get working, remove this next line $wp_rewrite->flush_rules(false); } … Read more

Force core to use .dev JavaScript files

I use a combination of constants on my local install. define(‘CONCATENATE_SCRIPTS’, false); define(‘COMPRESS_SCRIPTS’, false); // <— this is likely the one you’re after define(‘COMPRESS_CSS’, false); define(‘SCRIPT_DEBUG’, true); I’d imagine the second constant listed above is the one you’re after.

How to add checkbox and radio button in Profile Page

You are missing the “checked” value for the inputs <input type=”checkbox” name=”language” <?php if (get_the_author_meta( ‘language’, $user->ID) == ‘Mandarin’ ) { ?>checked=”checked”<?php }?> value=”Mandarin” /> Mandarin<br /> Also, the usermeta is dealing but your are checking for $_POST[‘gender’] Finally, you should have one usermeta for English and other for Mandarin, as they are not mutually … Read more

Change admin startpage to Pages-page?

This should work for you if you put it in your themes functions.php file, but you may want to modify the conditions, and the url to redirect to depending on your set up. function loginRedirect( $redirect_to, $request, $user ){ if( is_array( $user->roles ) ) { // check if user has a role return “/wp-admin/edit.php?post_type=page”; } … Read more

Creating a rotating header /image slider using theme customization

We can do that! First, you’ll need to add a custom section on the Theme Customizer, containing all the image uploads (we’ll use 3 for this example): add_action( ‘customize_register’, ‘themename_customize_register’ ); function themename_customize_register($wp_customize) { $wp_customize->add_section( ‘slides’, array( ‘title’ => ‘Slides’, ‘priority’ => 25, ) ); $wp_customize->add_setting( ‘first_slide’, array( ‘default’ => ”, ) ); $wp_customize->add_control( new … Read more

Modify search function in WordPress (TwentyTwelve)

Modify the searchform.php, or create one in a child theme (recommended), and you should be able to modify the form all you want. This is the file that get_search_form looks for and is the file used by the default search widget, though it is not listed in the Template Hierarchy. Reference: http://codex.wordpress.org/Function_Reference/get_search_form