S
S
Sergey2018-09-05 12:16:40
WordPress
Sergey, 2018-09-05 12:16:40

What is the best way to display news on the site through WordPress?

It is necessary to make sure that the site has a news page with a transition to the page of the corresponding news, it is also necessary that the last 3 news are displayed on the main page. Plus, there will still be a similar structure, only it will no longer be news, but other blocks.
How to do it? Through posts and rubrics? If so, how?
I also have the Advanced Custom Fields Pro plugin installed. Maybe through it is better somehow?

Answer the question

In order to leave comments, you need to log in

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

Through posts and rubrics?

No way, you're all mixed up.
For all entities (sections), create custom post types. This can be done both through plugins and 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' );

Replace "vacancies" with "news", "vacancy" with "news". Thus, the corresponding "news" section will appear in the admin panel, separately from the "post" or "page", and all news will be available on the /news page, the code of which can be specified in archive-news.php.
You can display news on the main page through the Wordpress cycle by changing the post_type.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question