Last active
September 3, 2023 20:29
-
-
Save azizultex/ae7ddab5c4a388c1056e0bfa0a9473ad to your computer and use it in GitHub Desktop.
Override a plugin shortcode in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Best way to override a plugin function is to use mu-plugins (Must Use Plugins) | |
https://gregrickaby.com/2013/10/create-mu-plugin-for-wordpress/#comment-14420 | |
Aleternatively, follow below : | |
1. Copy the plugin shortcode function and put it anywhere in Child Theme and rename it like custom_cs_user_login_shortcode. | |
2. use 'wp_head' action to remove the plugin shortcode and register the new shortcode again with the new function name like custom_cs_user_login_shortcode. | |
/********************************************* | |
EXAMPLE | |
********************************************* / | |
require_once 'override/wp-jobhunt/shortcodes.php'; | |
add_action('wp_head','override_cs_user_login'); | |
function override_cs_user_login() { | |
remove_shortcode('cs_user_login'); | |
add_shortcode('cs_user_login', 'custom_cs_user_login_shortcode'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order to remove an Actions from a Plugin Class Method WordPress follow : https://gist.github.com/azizultex/dd55c5c0518a427ae3a5552f683eb29b