Add field to ‘Add User’ admin page

Here’s the way I have always done it. All of this code goes in functions.php. Of course this adds a whole new section to the user profile. add_action( ‘show_user_profile’, ‘be_show_extra_profile_fields’ ); add_action( ‘edit_user_profile’, ‘be_show_extra_profile_fields’ ); function be_show_extra_profile_fields( $user ) { ?> <h3>Extra Contact Information</h3> <table class=”form-table”> <tr> <th><label for=”contact”>Contact Number</label></th> <td> <input type=”text” name=”contact” id=”contact” … Read more

Making menu link open in new tab?

You can do that with jQuery. We can open this link in new tab/window by adding target=”_blank” attribute dynamically on link which has URL https://www.example.com. Here is the example function for that. function wpse_my_custom_script() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { $( “ul#adminmenu a[href$=’https://www.example.com’]” ).attr( ‘target’, ‘_blank’ ); }); </script> <?php } add_action( ‘admin_head’, ‘wpse_my_custom_script’ … Read more

Theme menu in Admin Panel

You need to register custom menus in your theme – https://codex.wordpress.org/Function_Reference/register_nav_menu You first need to register your menu in functions.php like so: add_action( ‘after_setup_theme’, ‘register_my_menu’ ); function register_my_menu() { register_nav_menu( ‘primary’, __( ‘Primary Menu’, ‘theme-slug’ ) ); } Then, where you want your menu to appear – usually header.php – you call the function: wp_nav_menu()

Prevent /wp-admin/ from redirecting to homepage?

In my case, it ended up being some kind of adverse interaction in the nginx wordpress config that I had. Something about not passing along the naked arguments: location / { original line: try_files $uri @php; new line: try_files $uri $uri/ /index.php?$args; } And the associated upstream was wrong. Used the config suggested here: https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/ … Read more

Remove/Add widgets from/to the Available Widgets pool

You can use the function unregister_widget to remove widgets. E.g. you can remove the Calendar widget with: function my_widgets_init() { unregister_widget( ‘WP_Widget_Calendar’ ); } add_action(‘widgets_init’, ‘my_widgets_init’); To add widgets, use the Widgets API.