L
L
likeh8r2018-09-05 08:19:25
Internationalization and localization
likeh8r, 2018-09-05 08:19:25

WordPress. How to properly implement a custom news section with multilingualism?

Hello. There is a multilingual site on Wordpress (multilingualism implemented using polylang). There are a number of elements on the site that are planned to be changed/added/removed from time to time.
For example, available vacancies. All of them are available on the "Jobs" page, in the footer of the site.
The question is how to properly implement the admin part to interact with these vacancies? So that an inexperienced user entering the admin panel can easily add / edit existing vacancies, taking into account multilingualism (so that he does not have to declare new variables in polylang every time). That is, something as close as possible to standard records.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2018-09-05
@Vnevremen

You simply create a custom post type that will be available in the admin panel as a separate section, just like "posts" or "pages". This can be done both through plugins and by inserting code into functions.php:

// регистрируем тип записей Вакансии
function register_vacancy_entities() {
  $vacancy_args = array(
    'public' => true,
    'label'  => null,
    'labels' => array(
      'name'               => 'Вакансии',
      'singular_name'      => 'Вакансия',
      'add_new'            => 'Добавить вакансию',
      'add_new_item'       => 'Добавление вакансии',
      'edit_item'          => 'Редактирование вакансии',
      'new_item'           => 'Новая вакансия',
      'view_item'          => 'Смотреть страницу вакансии',
      'search_items'       => 'Искать вакансии',
      'not_found'          => 'Не найдено',
      'not_found_in_trash' => 'Не найдено в корзине',
      'parent_item_colon'  => '',
      'menu_name'          => 'Вакансии',
    ),
    'menu_position' => 5,
    'menu_icon' => 'dashicons-admin-users',
    'rewrite' => array( 'slug' => 'vacancy' ),
    'has_archive' => true
  );
  register_post_type( 'vacancy', $vacancy_args );
}

add_action( 'init', 'register_vacancy_entities' );

Because all vacancies most likely have common parameters, most likely it will be logical to add custom fields for this post type, for this I recommend the ACF plugin.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question