'Sections', 'singular_name' => 'Section', 'add_new' => 'Add section', 'all_items' => 'All sections', 'add_new_item' => 'Add section', 'edit_item' => 'Edit section', 'new_item' => 'New section', 'view_item' => 'View section', 'search_items' => 'Search section', 'not_found' => 'No sections found', 'not_found_in_trash' => 'No sections found in trash', 'parent_item_colon' => 'Parent section' ); $args = array( 'labels' => $labels, 'public' => true, 'has_archive' => true, 'publicly_queryable' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'menu_icon' => 'dashicons-exerpt-view', 'hierarchical' => false, 'supports' => array( 'title', 'editor', //'excerpt', 'thumbnail', //'author', //'trackbacks', //'custom-fields', //'comments', 'revisions', //'page-attributes', // (menu order, hierarchical must be true to show Parent option) //'post-formats', ), 'taxonomies' => array( ), // add default post categories and tags 'menu_position' => 21, 'exclude_from_search' => false, ); register_post_type( 'section', $args ); /*register_taxonomy( 'sectionparent', 'section', array( 'hierarchical' => true, 'show_ui' => true, 'labels' => array( 'name' => 'Section Parent', 'singular_name' => 'Section Parent', ), 'query_var'=>true, 'public'=>true, ) );*/ } add_action( 'init', 'sectionizer_create_post_type' ); add_action('restrict_manage_posts','restrict_sections_by_page'); function restrict_sections_by_page() { global $typenow; if ($typenow=='section') { return wp_dropdown_pages(array( 'show_option_all' => __("Show All Pages"), 'name' => 'sectionparent', 'orderby' => 'name', 'selected' => isset($_REQUEST['sectionparent']) ? $_REQUEST['sectionparent'] : null , 'show_option_none' => 'Alle pagina\'s', )); } } add_filter('parse_query','convert_page_id_to_taxonomy_term_in_query'); function convert_page_id_to_taxonomy_term_in_query($query) { global $pagenow; $qv = &$query->query_vars; if ($pagenow=='edit.php' && $qv['post_type']=='section' && isset($_REQUEST['sectionparent']) && $_REQUEST['sectionparent']) { $qv['meta_query'] = array( 'relation' => 'AND', array( 'key' => 'pagina', 'value' => $_REQUEST['sectionparent'], 'compare' => '=' ) ); } } endif; // end of function_exists() //register ACF /* if(function_exists("register_field_group")) { register_field_group(array ( 'id' => 'acf_sectionizer', 'title' => 'sectionizer', 'fields' => array ( array ( 'key' => 'field_5704ba492192d', 'label' => 'Pagina', 'name' => 'pagina', 'type' => 'page_link', 'post_type' => array ( 0 => 'page', ), 'allow_null' => 0, 'multiple' => 0, ), ), 'location' => array ( array ( array ( 'param' => 'post_type', 'operator' => '==', 'value' => 'post', 'order_no' => 0, 'group_no' => 0, ), ), ), 'options' => array ( 'position' => 'normal', 'layout' => 'no_box', 'hide_on_screen' => array ( ), ), 'menu_order' => 0, )); } */ //add button function to editor function register_addbutton( $buttons ) { array_push( $buttons, "|", "addbutton" ); return $buttons; } function add_buttonplugin( $plugin_array ) { $plugin_array['addbutton'] = get_template_directory_uri() . '/includes/js/tinymce.js'; return $plugin_array; } function insertbutton_button() { if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) { return; } if ( get_user_option('rich_editing') == 'true' ) { add_filter( 'mce_external_plugins', 'add_buttonplugin' ); add_filter( 'mce_buttons', 'register_addbutton' ); } } add_action('init', 'insertbutton_button');