wrapping ‘rest_api_init’ in ‘is_admin()’ function

Essentially, you shouldn’t wrap your REST route declarations inside is_admin() since WordPress will not load them (see @DarkNueron comment). What you can do is pass a ‘permission_callback’ function to the register_rest_route function. If the function returns true, the request is allowed to continue; if false, an error is returned. So you could do: register_rest_route(‘your-namespace/v1’, ‘/options/’, … Read more

Automatically exclude categories from metabox based on title

You have chosen to tackle a hard problem for one so new to PHP. 🙂 This might get you closer to your goal: global $wpdb; if ( in_array( $pagenow, array(‘post.php’, ‘post-new.php’) ) ) { foreach (get_categories() as $category) { $cat_time = strtotime($category->cat_name); if ( $cat_time < strtotime(‘-3 days’) || $cat_time > strtotime(‘+2 months’) ) $exclude … Read more

Can’t call external stylesheet for WordPress admin (using wp_admin_css)?

You need to use wp_enqueue_style and hook it into admin_print_styles add_action( ‘admin_print_styles’ , ‘my_wp_admin_css’ ); function my_wp_admin_css() { wp_enqueue_style(‘my_admin_style’ , WP_PLUGIN_URL . ‘/myPlugin/stylesheet.css’ ); } If you just want the stylesheet on your plugins page you can use: $mypage = add_management_page( ‘myplugin’, ‘myplugin’, 9, __FILE__, ‘myplugin_admin_page’ ); add_action( “admin_print_styles-$mypage”, ‘myplugin_admin_head’ );   function myplugin_admin_head() { … Read more

Show an image in my header.php

WordPress contains built-in support to select header images for a theme. You only have to indicate that your theme supports this, by calling add_custom_image_header(). See the Twenty Ten initialization for details. In your theme’s header.php you then call header_image() to get the current header image.