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

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

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

How can I add an extra WooCommerce hook

You can create a hook by calling do_action, then referring to the hook in your functions.php with add_action. For example, in the theme, where you want the action to occur: do_action(‘woocommerce_before_single_product_intro’); Then in functions.php add_action(‘woocommerce_before_single_product_intro’,’your_function’,[…]); For the sake of maintainability, I’d choose a naming convention that doesn’t confuse your hooks with WooCommerce’s.

Change number of posts to show on Archive page (custom post type)

Just make sure you’re not in the admin when changing the query: function num_posts_archive_project_ie($query) { if (!is_admin() && $query->is_archive(‘projects-ie’) && $query->is_main_query()) { $query->set(‘posts_per_page’, 6); } return $query; } is_admin() does return true only if you’re in the backend (it does not, however, verify that the current user is an admin user, despite the name, don’t … Read more