Category: Code Snippets
-

Unhooking Actions Hooked Inside PHP Classes With remove_action
[ad_1] By OutsourcedContent — on April 13, 2018 Here is an example. The following snippet removes the action hooked from the SumoMe plugin – https://wordpress.org/plugins/sumome/ /** * Dequeue SumoMe inline script * * @author Arun Basil Lal */ function rocket_helper_dequeue_sumo_me_js() { global $wp_plugin_sumome; remove_action(‘admin_footer’, array( $wp_plugin_sumome, ‘append_admin_script_code’ ) ); } add_action( ‘admin_head’, ‘rocket_helper_dequeue_sumo_me_js’ );…
-

Read Plugin Version Of Any WordPress Plugin
[ad_1] By OutsourcedContent — on April 19, 2018 Using the get_file_data() function. More efficient than using get_plugin_data() function. $plugin_data = get_file_data( WP_PLUGIN_DIR . ‘/plugin-folder-name-in-wp-content-plugins-folder/plugin-main-file.php’, array( ‘Version’ => ‘Version’ ) ); $plugin_data[‘Version’] will have the version. To read version from within the same plugin: $plugin_data = get_file_data( __FILE__, array( ‘Version’ => ‘Version’ ) ); Refer: https://wordpress.stackexchange.com/a/285644/90061…
-

Add Custom Post Type To Tag And Category Archive Pages
[ad_1] By OutsourcedContent — on May 20, 2018 Here is how to modify the query for default taxonomy archive pages (tag archive page or category archive page) to display custom post types. /** * Add custom post types to the default tag query * * This will make sure that the custom post types…
-

Limit WordPress To Perform Search Through Post Titles Only
[ad_1] On a project, sometimes you may require WordPress to perform search through post titles only and exclude post content as well as post excerpts. Although it’s not very useful to exclude post content from searches because then you will get less relevant results and also less results in quantity, but on a special project…
-

Remove Comment Author Link In WordPress Comment List
[ad_1] By OutsourcedContent — on July 8, 2018 Add the following code snippet to the functions.php of your theme to remove the links to the comment author website in WordPress comments list. Works when the comments list is generated with wp_list_comments(). /** * Remove comment author link in WordPress comment list * * Removes…
-

Remove Website Field From WordPress Comment Form
[ad_1] By OutsourcedContent — on July 8, 2018 Remove the website / URL field in WordPress comment form. /** * Remove webiste field from WordPress comment form * * Removes the website field when comments form is displayed with comment_form() * * @since 1.0 */ function velocity_remove_comment_form_website_field( $fields ) { if (…
-

Quickly Enable Debug Mode On WordPress Website When Needed
[ad_1] If you have ever faced “WordPress white screen of death” then you probably already know that there is something wrong on your website and in situations like this, you must switch ON WordPress debug mode on your website to diagnose the issue. But to enable debug mode, you will require to edit WordPress configuration…
-

Update WordPress Password via SQL (No phpMyAdmin)
[ad_1] By OutsourcedContent — on April 15, 2019 Run this from a plugin or a file that will be executed. global $wpdb; $wpdb->query( “UPDATE wp_users SET user_pass= MD5(‘new-password’) WHERE user_login = ‘known-username'” ); Refer: https://stackoverflow.com/a/23635330/8255629 [ad_2]
-

Debug Tools For WordPress / PHP – current_filter and debug_backtrace
[ad_1] By OutsourcedContent — on June 11, 2019 We have already discussed error_log here. The current_filter() function will return the current WordPress filter or action calling a specific function. The return type is string, so it’s straight forward to just use it. Add the following inside the function to know which WordPress action or filter…
-

How to Display All Tags on Post Edit Page Instead of Frequently Used Tags
[ad_1] WordPress by default shows only 45 frequently used tags on post edit page in WordPress admin. In most of the cases it’s quite fine since most of the users do not have that many tags on their blog. But on a relatively large website, you may have hundreds of tags and you may require…