Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?

I realize you’ve already answered your issue. However, I think there is some additional explanation possible to give more clarity to the issue and the solution. The issue is your lqdnotes_add_div() function. This is hooked to a filter – the_content. In WordPress, any time you use a filter, your filter function must return a value … Read more

wp_loaded hook block script enquequing

You can’t enqueue because wp_loaded is too early. To enqueue scripts and styles, you need to do it on the wp_enqueue_scripts type hooks, but because your exiting on wp_loaded, none of those hooks have fired yet. Additionally, you need to have the necessary function calls in the template for it to enqueue them into, such … Read more

Prevent a plugin from being automatically activated

You might want to add your own plugin to deactivate their plugin (silently). First open their main plugin file and see where the plugin hooks (or filters) in. Then unhook their plugin … and your’s as well. <?php /** Plugin Name: Deactivate other plugin */ add_action( ‘the_same_hook’, ‘removeOtherPlugin’, PHP_INT_MAX -1 ); function removeOtherPlugin() { remove_filter( current_filter(), … Read more

How to remove query string from current page URL?

You don’t need $url = “https://”.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’]; for getting the current URL to remove the query string. All you need is remove_query_arg(‘the_query’, false). False, means it will use the current URL and your code can be shorten to: function abc_redirections(){ if(isset($_GET[‘query_string’]) || isset($_GET[‘query_string_1’])){ $array = array(); if(isset($_GET[‘query_string’]) && (empty($_GET[‘query_string’]) || !is_numeric($_GET[‘query_string’]) || (is_numeric($_GET[‘query_string’]) && $_GET[‘query_string’] < … Read more

Register post status, exclude from searches

If it was me, I would probably just override the queries on the individual templates that you are trying to hide “ghosted” posts on. However, I can see how in some situations it would be better to override the main query. How about: function public_query_published_only($query) { if ( !$query->is_single() && !current_user_can(‘manage_options’) && !is_admin() ) { … Read more

How to pull code snippet from functionality plugin?

You’re trying to echo <?php tags, but that won’t work: they won’t be processed. Instead you need to replicate that logic in PHP statements in your function instead. Here’s a partial answer: function epf_extra_buttons( $post_ID ) { // TODO: where does $es_settings come from? $encoded_permalink = urlencode(get_the_permalink()); if ( $es_settings->share_facebook ) { echo ‘<a class=”a2a_button_facebook” … Read more