Execute a plugin only on post pages

No, the plugin is loaded long before WordPress has figured out if it should display a single post. But you can restrict the code of the plugin to do something only then. Example: add_action( ‘template_redirect’, function() { if ( ! is_single() ) return; // initialize plugin code here. });

WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page

I’ll preface this by saying I think it’s a really bad idea, but you could circumvent the admin UI by hooking an action that happens after things are initialized, but before any output occurs: function my_admin_ui(){ if( isset( $_GET[‘page’] ) && ‘myPlugin-ui’ == $_GET[‘page’] ){ include( plugin_dir_path( __FILE__ ) . ‘views/myPlugin-ui.php’ ); exit; } } … Read more

Problem with wordpress version 3.8

Deactivate flash album gallery plugin then try again may be this plugin version not match to wordpress latest version. This plugin may not be compatible with wordpress 3.8, you must wait for the new release. Nonetheless, they are just notices you can simply hide these notices by going wp-config.php and toggle WP_DEBUG to false.

How to update billing_email when user_email is updated [closed]

This code should do it for you. It add an action to the updating of the WordPress profile, checks if the email has been updated, and if so, it updates the Woocommerce address as well. add_action(‘profile_update’, ‘sync_woocommerce_email’, 10, 2) ; function sync_woocommerce_email( $user_id, $old_user_data ) { $current_user = wp_get_current_user(); if ($current_user->user_email != $old_user_data->user_email) { wp_update_user( … Read more

Set the active Navigation Menu from a plugin

You can use the wp_nav_menu_args filter ( Codex reference ) to set a theme location to use a specific menu. Example: function test_wp_nav_menu_args( $args=”” ) { // only set menu for the primary navigation menu. if ( $args[‘theme_location’] != ‘primary’ ) { return $args; } // change {main-menu} to be the slug of the menu … Read more

How do i save plugin-specific info?

I would recommend you store it as an option Here is the API: add_option( $option, $value, $deprecated, $autoload ); update_option( $option, $new_value ); get_option( $option, $default ); delete_option( $option ); For your option I would not set autoload to true for performance reasons ( unless you are grabbing this option on every page ). I … Read more