How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286

Replace ‘call_user_func_array’ with name of the function to be called to output the page content. add_action(‘admin_menu’, ‘personalised_menu’); function personalised_menu() { add_menu_page( ‘Page Title’, ‘Blog’, ‘edit_posts’, ‘menu_slug’, ‘display_main_page’, ‘dashicons-welcome-write-blog’ ); add_submenu_page( ‘menu_slug’, ‘Add New Page’, ‘Add New’, ‘edit_posts’,’add_new_page’, ‘display_secondary_page’ ); } function display_main_page() { echo ‘Content of “Page Title”‘; } function display_secondary_page() { echo ‘Content of … Read more

Checking the count within a foreach loop

You can achieve this very easily, just count the array with the terms. Also if I could suggest something more, I’d check for WP_Error a bit earlier, outside the foreach loop, instead of checking every single term, especially that you’re not using the $term_link variable anywhere. Just checking if get_the_terms() returns an array should be … Read more

Undefined index: action with code-snippets to change register page

You’re doing this: strtolower( $_GET[‘action’]) But you’re not checking if $_GET[‘action’] exists first. You can’t count on it being set, because when you visit wp-login.php, it doesn’t have ?action= in the URL, but this hook still fires. So you need to add isset( $_GET[‘action’] ) to your conditions: if ( strtolower($pagenow) == ‘wp-login.php’ && isset( … Read more

Read array in php?

Fastest way would be something like this: $fruit_id = get_user_meta($user_id, ‘fruit’, true); //returns 1 $display_fruit = some_fruits($fruit_id); //will return ‘Apple’

The Loop not looping?

I’m following your initial question. In your backend, create a page with the title Test 1, which should result in the page slug test-1. In your child theme folder, create a page template, using the filename page-test-1.php. WordPress will be loading this template, following this pattern: page-$slug.php. For more details, see here: https://developer.wordpress.org/files/2014/10/wp-hierarchy.png. In your … Read more

WordPress function, Run using Crontab

define(‘DISABLE_WP_CRON’, true); This line disables the default behaviour of WP Cron. Which is being triggered by a user that visits the site. This is bad for a couple of reasons (nobody might visit, tasks are started via apache handler instead of PHP CLI, …). Now, if you have disabled it, you need another way to … Read more

deactivating an active plugin using if page

Instead of deactivating the plugin completely (which would deactivate it everywhere on your site) look at the plugin’s code and determine what JS and CSS it is enqueuing. Then in your theme’s functions.php you can dequeue that plugin’s JS/CSS – but only on whatever pages you want to disable the plugin on. So for example, … Read more