Using wp_handle_upload() to Direct Specific Path by Using $overrides

You need to specify a list of allowed mime types. You could make it easy by just getting the allowed mime types like: $file = $_FILES[‘the-file’]; $upload_file = wp_handle_upload($file, array( ‘test_form’ => false, ‘mimes’ => get_allowed_mime_types() )); If you look at the codex for Default allowed mime types, you could manually specify which ever mime … Read more

Remove CSS & JS files from WordPress Main Page For Increase Pagespeed?

Does it work any better added to a hook with the conditionals inside? function my_deregisters() { if ( !is_single() ) { remove_action(‘wp_head’, ‘wp_page_numbers_stylesheet’); //wp_deregister_style( ‘fancybox’ ); // i think this can be removed //wp_deregister_script( ‘fancybox’ ); // i think this can be removed wp_dequeue_script(‘fancybox’); wp_dequeue_style(‘fancybox’); remove_action(‘wp_print_scripts’, ‘mfbfw_load’); remove_action(‘wp_print_styles’, ‘mfbfw_css’); remove_action(‘wp_head’, ‘mfbfw_init’); remove_action(‘wp_head’, ‘cforms_style’); } } … Read more

Custom view counts not updating correctly

The issue was that the $query->set in the filter function was updating the main query used to count the number of posts. Likely due to the order in which they were called. I tried to flush and run a new wp_query but what ultimately worked best was the function below that uses a custom query. … Read more

How to add a filter to get_the_author_meta?

If you look in source, you’ll see the filter applied to get_the_author_meta calls: return apply_filters( ‘get_the_author_’ . $field, $value, $user_id ); So your filter should hook get_the_author_display_name.

Add Class to a div using a filter?

You could try using one of the following methods, I don’t think there is a specific way to do this other than these two options below. Option 1 In your template file, add the post_class(); to your div like this: <div id=”your-div” <?php post_class(); ?> > Then you can use post_class filter in your themes … Read more