diff --git a/functions.php b/functions.php index 14c81be..d0713dd 100755 --- a/functions.php +++ b/functions.php @@ -245,7 +245,8 @@ function add_category_class_to_posts($classes, $class, $post_id) { add_filter('post_class', 'add_category_class_to_posts', 10, 3); -require_once 'inc/opengraph.php'; +require_once 'inc/opengraph.php'; //опенграф +require_once 'inc/postdate.php'; //постдаты diff --git a/inc/postdate.php b/inc/postdate.php new file mode 100644 index 0000000..02f965a --- /dev/null +++ b/inc/postdate.php @@ -0,0 +1,136 @@ + array( + 'name' => __('Постдаты'), + 'singular_name' => __('Постдата'), + 'add_new' => __('Добавить постдату'), + 'add_new_item' => __('Добавить новую постдату'), + 'edit_item' => __('Редактировать постдату'), + 'new_item' => __('Новая постдата'), + 'view_item' => __('Посмотреть постдату'), + 'search_items' => __('Искать постдаты'), + 'not_found' => __('Постдат не найдено'), + 'not_found_in_trash' => __('В корзине постдат не найдено'), + 'all_items' => __('Все постдаты'), + 'menu_name' => __('Постдаты') + ), + 'public' => true, + 'has_archive' => true, + 'supports' => array('title', 'editor'), // Убрали 'custom-fields' + 'menu_icon' => 'dashicons-calendar-alt', + 'rewrite' => array('slug' => 'postdaty') + ) + ); +} +add_action('init', 'create_postdaty_post_type'); + + + +// Добавление метабокса +function add_postdata_date_meta_box() { + add_meta_box( + 'postdata_date_meta_box', + 'Дата события', + 'postdata_date_meta_box_html', + 'postdaty', + 'side', + 'default' + ); +} +add_action('add_meta_boxes', 'add_postdata_date_meta_box'); + +// HTML метабокса +function postdata_date_meta_box_html($post) { + $event_date = get_post_meta($post->ID, '_postdata_event_date', true); + wp_nonce_field('postdata_date_nonce', 'postdata_date_nonce_field'); + ?> + + + ID, '_postdata_related_biography', true); + wp_nonce_field('postdata_biography_nonce', 'postdata_biography_nonce_field'); + + // Получаем посты только из рубрики 10723 + $biographies = get_posts(array( + 'post_type' => 'post', + 'posts_per_page' => -1, + 'orderby' => 'title', + 'order' => 'ASC', + 'cat' => 10723 // ID рубрики + )); + ?> + + + + +
+ Показаны только посты из рубрики биографий +
+