How to correct schedule my event weekly with wp_schedule_event()

According to the docs for this function, you can’t set up a weekly event by default. wp_schedule_event(int $timestamp, string $recurrence, string $hook, $args = array() ); The $recurrence value needs to be one of: “hourly” “twicedaily” “daily” You’ll need to test today’s date inside your callback function, my_event. Something like: function my_event() { # date(‘l’) … Read more

Organize functions.php

Doing this simply won’t make a significant performance difference, instead organize your customizations with clear headings so you can find and edit things faster later… in other words, organize for development in this case, not for the frontend. There are plenty of other optimizations that can be done with some research but this just isn’t … Read more

what is the meaning of settings_fields()

Via the Developer Reference (not the Codex) Output nonce, action, and option_page fields for a settings page. Here’s the source code for it function settings_fields($option_group) { echo “<input type=”hidden” name=”option_page” value=”” . esc_attr($option_group) . “” />”; echo ‘<input type=”hidden” name=”action” value=”update” />’; wp_nonce_field(“$option_group-options”); } so, it gives the form processor some info to work with … Read more

Dynamic URL to reference custom PHP files

I’m not positive I understand the question, but if you’re just trying to get the site URL, you can use the get_site_url() WP function. So, like this: $siteURL = get_site_url(); header(“=Location: $siteURL” . “/myoriginalformpage/?success=”, $success); And you can change the parameters of get_site_url() to specify the path and to display ‘https’ or ‘http’. But if … Read more

Return only top-level navigation items from a menu using wp_get_nav_menu_items

Let’s take a look at wp_get_nav_menu_items code reference. It takes two parameters: $menu – (int|string|WP_Term) (Required) Menu ID, slug, name, or object, $args – (array) (Optional) Arguments to pass to get_posts(). So we can use get_posts args in here… And if we want to get only top-level posts, then post_parent arg comes useful… So something … Read more

wp_delete_user with username

There is no way to do this with only one query. But to be honest – deleting user takes more than one query itself… You shouldn’t use custom SQL for that, because there are many things you could break this way… Always use WP functions, if they exists (what if some plugin logs every deleted … Read more

Order by two meta keys

I’m not 100% certain what specific order you’re asking for, but you just need to assign an associative array to the ‘orderby’ value. Here’s an example: $args = array( ‘post_type’ => ‘brands’, ‘meta_query’ => array( array( ‘key’ => ‘br_type’, ‘value’ => ‘Aviation’ ), array( ‘key’ => ‘br_category’ ), array( ‘key’ => ‘br_name’ ) ), ‘posts_per_page’ … Read more

Make sub menu items a main link in the admin menu using fuctions.php

OK, it’s a bit messy, but it works. Take a look function remove_submenus() { global $submenu; unset($submenu[‘themes.php’][10]); // Removes Menu } add_action(‘admin_menu’, ‘remove_submenus’); function new_nav_menu () { global $menu; $menu[99] = array(”, ‘read’, ‘separator’, ”, ‘menu-top menu-nav’); add_menu_page(__(‘Nav Menus’, ‘mav-menus’), __(‘Nav Menus’, ‘nav-menus’), ‘edit_themes’, ‘nav-menus.php’, ”, 99); } add_action(‘admin_menu’, ‘new_nav_menu’); Essentially it is removing the … Read more