How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?

I coded a plugin just for that and never got around to publish it : Usage: In the dropdown you have a list of all custom fields, so just select the field you want to filter by and click filter. if you want to filter to a specific value of a custom field then select … Read more

How to put logs in WordPress

You can enable WordPress logging adding this to wp-config.php: // Enable WP_DEBUG mode define( ‘WP_DEBUG’, true ); // Enable Debug logging to the /wp-content/debug.log file define( ‘WP_DEBUG_LOG’, true ); you can write to the log file using the error_log() function provided by PHP. The following code snippet is a very useful function wrapper for it, … Read more

Opinions and recommendations on the best barebones base theme [closed]

Bare bone themes are great, personally I prefer them over frameworks. I have noticed that ‘liking’ one over another comes down to how it feels, so I would suggest trying several out until you find one. For instance a lot people like WordPress boilerplate but I could not get the hang of it. My current … Read more

How to create a custom search for custom post type?

Here is what I’ve tried and got a solution with 3 steps. Let’s say your custom post type is “products“ 1 . Add Function Code here you can specify the archive-search.php function template_chooser($template) { global $wp_query; $post_type = get_query_var(‘post_type’); if( $wp_query->is_search && $post_type == ‘products’ ) { return locate_template(‘archive-search.php’); // redirect to archive-search.php } return … Read more

How to remove admin menu pages inserted by plugins?

You need to use the right hooks (which are not always the same as the URLs/slugs), and it doesn’t hurt to use a hook that runs later (e.g., admin_init): add_action( ‘admin_init’, ‘wpse_136058_remove_menu_pages’ ); function wpse_136058_remove_menu_pages() { remove_menu_page( ‘edit.php?post_type=acf’ ); remove_menu_page( ‘wpcf7’ ); } You can use the following to debug: add_action( ‘admin_init’, ‘wpse_136058_debug_admin_menu’ ); function … Read more

Best collection of code for your .htaccess file [closed]

These are 3 snippet for better performance, regarding Yahoo! rules: Disable Etags: Header unset ETag FileETag None Add expire headers: <FilesMatch “\.(ico|jpg|jpeg|png|gif|js|css|swf)$”> Header set Expires “Tue, 16 Jun 2020 20:00:00 GMT” </FilesMatch> Or ExpiresActive On ExpiresByType text/html “access plus 1 day” ExpiresByType image/gif “access plus 10 years” ExpiresByType image/jpeg “access plus 10 years” ExpiresByType image/png … Read more

How to change the default registration email ? (plugin and/or non-plugin)

The new user email is sent using the wp_new_user_notification() function. This function is pluggable, which means that you can overwrite it: // Redefine user notification function if ( !function_exists(‘wp_new_user_notification’) ) { function wp_new_user_notification( $user_id, $plaintext_pass=”” ) { $user = new WP_User($user_id); $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); $message = sprintf(__(‘New user registration on your blog … Read more