WP Pages: Add checkbox, save and display

Why are you using $_REQUEST[‘featured-page’]? Your input name is _featured-page and you should use $_POST not $_REQUEST. Try something like this. add_action(“admin_init”, “register_post_assets”); function register_post_assets(){ add_meta_box(‘featured-page’, __(‘Featured Page’), ‘add_featured_meta_box’, ‘page’, ‘advanced’, ‘high’); } function add_featured_meta_box( $post ){ global $post; $custom = get_post_custom($post->ID); $_featured-page = $custom[“_featured-page”][0]; ?> <label>Featured Page</label> <?php $is_featured = get_post_meta($post->ID, ‘_featured-page’, true); $checked … Read more

Disable `create_post` for built-in post type

There is no built-in capability of create_post. Update: There is a capability create_posts but it’s not well publicised and also has issues surrounding it which I’m afraid I don’t have time to look into at the moment. There are already answers that might help: https://stackoverflow.com/a/3248103 https://wordpress.stackexchange.com/a/178059/94267 Original answer: There is publish_posts. You need to turn … Read more

Only get post_id [duplicate]

Quick shot: $countries = get_pages(array( “hierarchical” => 0, “sort_column” => “menu_order”, “sort_order” => “desc”, “meta_key” => “page_type”, “meta_value” => 2, )); $page_ids = array(); foreach ( $countries as $country ) { $page_ids[] = $country->ID; }