One of WP Ghost’s security features is disabling right-clicking on the front end to prevent users from easily copying your content. However, you might want to enable right-click on specific URLs selectively.
This tutorial will show you how to customize the right-click disable feature in WP Ghost using the provided code snippet.
Before customizing the right-click disable feature, you need access to edit the theme functions.php file from WordPress > Appearance > Theme File Editor.

Step-by-Step Guide:
Activate Disable Right Click
First, you need to activate Disable Right Click from WP Ghost > Tweaks > Disable Options.
- Go to WP Ghost > Tweaks > Disable Options.
- Switch on, Disable Right-Click feature to disable the mouse right-click in frontend.
- Click the Save button to apply the changes.

Add Theme Hook Code
Use the theme File Editor to open the functions.php file for editing. Insert the following code:
/**
* Deactivate disable right click on specific URLs
* array $urls List of URLs where the right click should be active
*/
add_filter('hmwp_option_hmwp_disable_click', function($active){
if(isset($_SERVER['REQUEST_URI'])) {
$urls = array(
home_url(), //home page
home_url('hello-world'),
home_url('sample-page'),
);
$path = rtrim($_SERVER['REQUEST_URI'], '/') . '/';
$paths = array_map(function ($url){
return trailingslashit(parse_url($url, PHP_URL_PATH));
}, $urls);
//don't activate on Home Page
if (in_array($path, $paths)) {
$active = false;
}
}
return $active;
});
You can do the same for these WP ghost hooks:
- hmwp_option_hmwp_disable_inspect <- Disable Inspect Element
- hmwp_option_hmwp_disable_source <- Disable View Source
- hmwp_option_hmwp_disable_copy_paste <- Disable Copy Paste
- hmwp_option_hmwp_disable_drag_drop <- Disable Drag-Drop Images
Customize the URLs
In the code snippet, you can see an array called $urls
. This array contains the URLs where you want to either enable or disable right-click. By default, the code allows right-click on the home page, ‘hello-world’, and ‘sample-page’.
You can customize this array by adding or removing URLs that match your specific requirements. Just make sure to follow the same format as the provided URLs.
Save Changes
After adding the code and customizing the URLs, save the changes to the file and check the results.

Visit the URLs you’ve customized in your browser and test the right-click functionality. Depending on your configuration, it should be enabled or disabled.
Conclusion
By following this tutorial and adding the provided code to your chosen file, you can selectively enable or disable right-click functionality on specific URLs, enhancing the user experience while maintaining security.