Get user id from email?

You are probably looking for the user_exists function. http://codex.wordpress.org/Function_Reference/email_exists This function will check whether or not a given email address ($email) has already been registered to a username, and returns that users ID (or false if none exists). If the email address does not exist (user_exists returns false), you may want to use the wp_create_user … Read more

Use ‘add_theme_support’ instead of ‘add_custom_image_header’ In WordPress 3.4

Please read Updating Custom Backgrounds and Custom Headers for WordPress 3.4. Custom Headers Old method: // Define default header image constant define( ‘HEADER_IMAGE’, get_template_directory_uri() . ‘/images/headers/default.jpg’ ); // Define header image width constant define( ‘HEADER_IMAGE_WIDTH’, 1000 ); // Define header image height constant define( ‘HEADER_IMAGE_HEIGHT’, 198 ); // Define header text constant define( ‘NO_HEADER_TEXT’, false … Read more

wp_is_mobile function

No, it will fail. There are literally thousands of mobile clients, and not all send a usable User-Agent header. There are better ways to adjust the site to small screens (which is not necessary the same as mobile!). Use client side detection and offer a link to switch the view; save that option in a … Read more

How to remove a metabox from menu editor page?

By inspecting the file /wp-admin/nav-menus.php we can see that these meta-boxes: are rendered with: <?php do_meta_boxes( ‘nav-menus’, ‘side’, null ); ?> The file /wp-admin/includes/nav-menu.php contains the corresponding add_meta_box() calls and from that we can construct the relevant removal code: function custom_remove() { remove_meta_box(‘nav-menu-theme-locations’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-custom-links’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-post’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-page’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-category’, … Read more

Add body class of category parent

Use get_ancestors() to get the parent terms. Here is an excerpt from my plugin T5 Parent Terms in body_class: $ancestors = get_ancestors( get_queried_object_id(), get_queried_object()->taxonomy ); if ( empty ( $ancestors ) ) { return $classes; } foreach ( $ancestors as $ancestor ) { $term = get_term( $ancestor, get_queried_object()->taxonomy ); $new_classes[] = esc_attr( “parent-$term->taxonomy-$term->slug” ); } … Read more

Date archives for custom post type

What you want can be done also filtering ‘month_link’ for monthly archives, ‘year_link’ for yearly archives and ‘day_link’ for daily archives. You can also write a function that extends wp_get_archives to work with CPTs, adding filters to ‘getarchives_where’ and to the archive link. function wp_get_cpt_archives( $cpt=”post”, $args = array() ) { // if cpt is … Read more

Is it possible to override this function/class in a child theme?

You simply need to run your code on a higher priority than what the parent theme is, the default on add_action function is 10 so you can use: function s157343_unregister_widgets() { unregister_widget( ‘Chocolat_Widget_New_Entrys’ ); } add_action( ‘widgets_init’, ‘s157343_unregister_widgets’, 20 ); This will unregister that widget. Of course, you can still create a new class that … Read more