From f2d7deeedf567acd4d079a6cc31fd53c39848ddf Mon Sep 17 00:00:00 2001 From: argoexpert press Date: Mon, 26 May 2025 19:33:14 +0300 Subject: [PATCH] add spavochniki and rfo --- archive-spravochniki.php | 28 +++++ category-partners.php | 2 +- footer-rfo.php | 97 +++++++++++++++++ frontend/src/styles/pages/main.css | 7 ++ functions.php | 5 +- header-rfo.php | 163 +++++++++++++++++++++++++++++ inc/spravochniki.php | 90 ++++++++++++++++ sidebar-left.php | 8 +- single-spravochniki.php | 79 ++++++++++++++ taxonomy-spravochnik_cat.php | 28 +++++ 10 files changed, 500 insertions(+), 7 deletions(-) create mode 100644 archive-spravochniki.php create mode 100644 footer-rfo.php create mode 100644 header-rfo.php create mode 100644 inc/spravochniki.php create mode 100644 single-spravochniki.php create mode 100644 taxonomy-spravochnik_cat.php diff --git a/archive-spravochniki.php b/archive-spravochniki.php new file mode 100644 index 0000000..4c00a03 --- /dev/null +++ b/archive-spravochniki.php @@ -0,0 +1,28 @@ + +
+ +
+ name : get_the_title(); + ?> +

+ +
+
+ 'post', + 'posts_per_page' => 10, + 'paged' => $paged + ); + $query = new WP_Query($args); + + ?> + $wp_query]); ?> +
+ +
+ diff --git a/category-partners.php b/category-partners.php index 0d47053..3241a1d 100644 --- a/category-partners.php +++ b/category-partners.php @@ -21,7 +21,7 @@ $partners = new WP_Query([ $partners->the_post(); ?> -
+ +
+ + +
+ + + + + + + + \ No newline at end of file diff --git a/frontend/src/styles/pages/main.css b/frontend/src/styles/pages/main.css index 99a8843..d04f5b6 100644 --- a/frontend/src/styles/pages/main.css +++ b/frontend/src/styles/pages/main.css @@ -80,6 +80,13 @@ ul.wp-block-list li{ background: var(--secondary); } +.partner-logo IMG{ + height: auto; + display: block; + width: 150px; + max-width: 150px; +} + @media (max-width: 1439px) { .content { diff --git a/functions.php b/functions.php index 47f3e28..f9bcdca 100644 --- a/functions.php +++ b/functions.php @@ -2,6 +2,7 @@ setlocale(LC_TIME, 'ru_RU.UTF-8'); require get_template_directory() . '/inc/rubrics-menu.php'; // Рубрики в меню +require get_template_directory() . '/inc/spravochniki.php'; // Подключаем справочники // Полностью отключить XML-RPC add_filter( 'xmlrpc_enabled', '__return_false' ); @@ -1277,7 +1278,7 @@ function replace_first_figure_in_content($content) { add_filter('get_terms', function($terms, $taxonomies, $args) { global $pagenow; if (($pagenow === 'post.php' || $pagenow === 'post-new.php') && in_array('category', $taxonomies)) { - $exclude_ids = [7]; // ID рубрик, которые нужно скрыть + $exclude_ids = [7, 740, 741, 742, 743, 744, 745, 746, 762]; // ID рубрик, которые нужно скрыть $terms = array_filter($terms, fn($term) => !in_array($term->term_id, $exclude_ids)); } return $terms; @@ -1285,7 +1286,7 @@ add_filter('get_terms', function($terms, $taxonomies, $args) { // Для REST API (панель справа в редакторе Gutenberg) add_filter('rest_category_query', function($args, $request) { - $args['exclude'] = [7]; // Те же ID, что и выше + $args['exclude'] = [7, 740, 741, 742, 743, 744, 745, 746, 762]; // Те же ID, что и выше return $args; }, 10, 2); diff --git a/header-rfo.php b/header-rfo.php new file mode 100644 index 0000000..d32e237 --- /dev/null +++ b/header-rfo.php @@ -0,0 +1,163 @@ + +> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +> + +
+ + + + +
+
+ +
+
+ +
+ +
+
+
+
+ + +
+ + +
+
+
+ +
+
+

Главное сегодня

+ +
+
+
+
+
+ + + +
+
+ +
+ +
+ + \ No newline at end of file diff --git a/inc/spravochniki.php b/inc/spravochniki.php new file mode 100644 index 0000000..a84f32a --- /dev/null +++ b/inc/spravochniki.php @@ -0,0 +1,90 @@ + [ + 'menu_name' => 'Справочники', + 'name' => 'Статьи', + 'singular_name' => 'Статья', + 'add_new' => 'Добавить статью', + 'add_new_item' => 'Добавить новую статью', + 'edit_item' => 'Редактировать статью', + 'new_item' => 'Новая статья', + 'view_item' => 'Посмотреть статью', + 'search_items' => 'Искать статью', + 'not_found' => 'Не найдено', + 'not_found_in_trash' => 'В корзине не найдено', + ], + 'public' => true, + 'has_archive' => false, + 'rewrite' => true, // переопределим вручную + 'hierarchical' => false, + 'supports' => ['title', 'editor', 'excerpt', 'thumbnail'], + 'taxonomies' => ['spravochnik_category'], // прикрепим свою таксономию + 'show_in_rest' => true, // поддержка Gutenberg + 'menu_icon' => 'dashicons-book-alt', + ]); + + // Таксономия: рубрики справочников + register_taxonomy('spravochnik_category', 'spravochniki', [ + 'labels' => [ + 'name' => 'Справочники', + 'singular_name' => 'Справочник', + 'search_items' => 'Искать справочник', + 'all_items' => 'Все справочники', + 'parent_item' => 'Родительская рубрика', + 'parent_item_colon' => 'Родительская рубрика:', + 'edit_item' => 'Редактировать справочник', + 'update_item' => 'Обновить справочник', + 'add_new_item' => 'Добавить новый справочник', + 'new_item_name' => 'Новое имя справочника', + 'menu_name' => 'Справочники', + ], + 'public' => true, + 'hierarchical' => true, + 'rewrite' => false, // переопределим вручную + 'show_in_rest' => true, + ]); +} + +add_action('init', 'agro_register_spravochniki_post_type'); + + +// Подзаголовок +function agro_allow_meta_boxes_in_gutenberg($use_block_editor, $post_type) { + if ($post_type === 'spravochniki') { + return true; // разрешаем Gutenberg + } + return $use_block_editor; +} +add_filter('use_block_editor_for_post_type', 'agro_allow_meta_boxes_in_gutenberg', 10, 2); + + +function agro_add_spravochnik_subtitle_meta_box() { + add_meta_box( + 'agro_spravochnik_subtitle', + 'Подзаголовок', + 'agro_spravochnik_subtitle_callback', + 'spravochniki', + 'side', + 'high' // <-- вот здесь! + ); +} +add_action('add_meta_boxes', 'agro_add_spravochnik_subtitle_meta_box'); + + +function agro_spravochnik_subtitle_callback($post) { + $subtitle = get_post_meta($post->ID, '_spravochnik_subtitle', true); + echo ''; +} + +function agro_save_spravochnik_subtitle($post_id) { + if (array_key_exists('spravochnik_subtitle', $_POST)) { + update_post_meta($post_id, '_spravochnik_subtitle', sanitize_text_field($_POST['spravochnik_subtitle'])); + } +} +add_action('save_post', 'agro_save_spravochnik_subtitle'); + + + + diff --git a/sidebar-left.php b/sidebar-left.php index 1b670a9..9165534 100644 --- a/sidebar-left.php +++ b/sidebar-left.php @@ -30,7 +30,9 @@ if ( in_category('interviews') ) {
- + + + @@ -49,6 +51,4 @@ if ( in_category('interviews') ) {
- - - \ No newline at end of file + \ No newline at end of file diff --git a/single-spravochniki.php b/single-spravochniki.php new file mode 100644 index 0000000..3358127 --- /dev/null +++ b/single-spravochniki.php @@ -0,0 +1,79 @@ + + + + + +
+ + +
+
+ + + + + + +
+ +
+ +

+ +

+ +
+ +
Подписывайтесь на нас в Дзен и Telegram
+
+
+ + + + + + + +
+

Еще по теме

+
+ +
+ 'partners', + 'post_status' => 'publish', + 'order' => 'ASC', + 'posts_per_page' => 4 + ]; + $posts = get_posts($args); + $counter = 0; + foreach ($posts as $post) : ?> +
+ +

+
+
+ +
+ + На главную +
+
+
+
+
+ + + \ No newline at end of file diff --git a/taxonomy-spravochnik_cat.php b/taxonomy-spravochnik_cat.php new file mode 100644 index 0000000..4c00a03 --- /dev/null +++ b/taxonomy-spravochnik_cat.php @@ -0,0 +1,28 @@ + +
+ +
+ name : get_the_title(); + ?> +

+ +
+
+ 'post', + 'posts_per_page' => 10, + 'paged' => $paged + ); + $query = new WP_Query($args); + + ?> + $wp_query]); ?> +
+ +
+