replace current_page_item class in menu

Add this line at top of your display element function: add_filter(‘nav_menu_css_class’, ‘add_active_class_to_nav_menu’); Add this line at bottom of your display element function: remove_filter(‘nav_menu_css_class’, ‘add_active_class_to_nav_menu’); Add this function somewhere in your themes functions.php: function add_active_class_to_nav_menu($classes) { if (in_array(‘current-menu-item’, $classes, true) || in_array(‘current_page_item’, $classes, true)) { $classes = array_diff($classes, array(‘current-menu-item’, ‘current_page_item’, ‘active’)); $classes[] = ‘active’; } return … Read more

How to pass variable via $callback_args for add_meta_box

Sometimes an example says more than a thousand words. Here’s a small plugin that will guide you: <?php ! defined( ‘ABSPATH’ ) AND exit; /** * Plugin Name: (#65981) »kaiser« Meta Box example * Plugin URI: http://goo.gl/ls6Q6 * Description: Example showing how to add a meta box with callback args * Author: Franz Josef Kaiser … Read more

Add_settings_field() parameterizing callback?

The last optional $args argument the you can pass to add_settings_fields() is passed to callback. So it seems you can use same callback just fine. Hope I am right because I just stumbled onto this two minutes ago because of discussion in chat. 🙂 PS looked through code and it’s indeed relatively recent, before ~2.9 … Read more

gutenberg dynamic block is returning 404

The handle() method is being called by an add_action(‘enqueue_block_editor_assets, [$block, ‘handle’]) method along with all the other blocks. Here lies the problem. The register_block_type is being called too late. Try to call the function inside the init action hook. You can see an example in the shortcode block of the core.

WP showing “warning: call_user_func_array()”, What to do?

The error you’re getting is showing, because somewhere on your site (your theme or one of your plugins) is registering a filter function that doesn’t exist. Somewhere in your code, there will be such line (or similar to it): add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); It may use different hook, so it may also look like: add_filter( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)