Prevent theme from activating [duplicate]

Using after_switch_theme will activate the theme (which is fine as we want to run the check within the context of the new theme). So if the check fails, we can simply switch back to the previous theme (passed via after_switch_theme as $oldtheme). If WPML is missing ($wpml_is_missing = true;) we will output an admin notice … Read more

WP_Query arguments to fetch custom post type posts which are in certain category?

If you want your main query to take in account your custom post type, you can do as shown below : function add_custom_post_type_to_query( $query ) { if ( $query->is_archive() && $query->is_main_query() ) { $query->set( ‘post_type’, array(‘post’, ‘my_custom_post_type’) ); } } add_action( ‘pre_get_posts’, ‘add_custom_post_type_to_query’ ); You can place the above code in your theme’s functions.php or … Read more

Add theme templates for child categories into the template hierarchy

Don’t use template_redirect to load alternate templates as you can break any functionality that uses this hook to run on a lower priority than yours. The right hook is template_include. This is according to Mark Jaquith, one of the WP lead developers. https://markjaquith.wordpress.com/2014/02/19/template_redirect-is-not-for-loading-templates/ That said, it might be more appropriate to use the category_template filter … Read more