Calling WordPress hook from within a class: call to undefined function error

On this line: add_action(‘admin_menu’, array($this, ‘create_menu_item’)); You are correctly passing the create_menu_item method of the current class to callback argument of the add_action() function. You just need to apply the same principle for the callbacks in the add_menu_page() function: add_menu_page( $value->post_title, $value->post_title, ‘manage_options’, $value->post_name.’-admin-page.php’, array( $this, ‘create_admin_page’ ), // <– Here ‘dashicons-location-alt’, 6 ); This … Read more

CSS loading as empty file in Custom Theme

This looks like an issue of “File Permission” to me. Please check the file permissions on the involved folders and files. You should find an option to change permission on the top bar or by right-clicking in cpanel. On the other hand, you can also right-click on a folder or a file and change its … Read more

Hide comment notification number and buttons in wp backend

you can try with this code. remove totally comment functionality in backed. Put this code in your current theme function.php file. <?php // Removes from admin menu add_action( ‘admin_menu’, ‘my_remove_admin_menus’ ); function my_remove_admin_menus() { remove_menu_page( ‘edit-comments.php’ ); } // Removes from post and pages add_action(‘init’, ‘remove_comment_support’, 100); function remove_comment_support() { remove_post_type_support( ‘post’, ‘comments’ ); remove_post_type_support( … Read more

How to remove title tag with this filter

This should have worked (the part of the sprintf at least as I don’t have access to the original code. Try give a higher number: add_filter( ‘generate_featured_image_output’ , ‘remove_image_title_archive’,100); Another solution will be removing the filter before applying yours, like this: remove_filter( ‘generate_featured_image_output’, ‘remove_image_title_archive’,10 ); Important: To remove a hook, the $function_to_remove and $priority arguments … Read more

Change username link in admin bar

Create the following directory and file. wp-content/mu-plugins/admin-bar-tweaks.php Or, you can add this to your theme’s functions.php file. In the script below, remember to set $new_url to whatever you desire. <?php // Requires PHP 5.4+. add_action( ‘admin_bar_menu’, function( $wp_admin_bar ) { $new_url=”http://example.com/custom/location”; if ( $wp_admin_bar->get_node( ‘my-account’) ) { $wp_admin_bar->add_node( [ ‘id’ => ‘my-account’, ‘href’ => $new_url, … Read more

PHP script to redirect traffic based on website accessed

I’am not absolutely sure what you mean but probably something like this may help you: if( $_SERVER[ ‘SERVER_NAME’ ] == ‘website1.com’ ): header( ‘Location: https://www.example.com/w1’ ); exit; elseif( $_SERVER[ ‘SERVER_NAME’ ] == ‘website2.com’ ): header( ‘Location: https://www.example.com/w2’ ); exit; endif;