@Pavel_sp

Как получить 2 значения get_posts()?

PHP не знаю, сильно не пинайте... Прошу помощи... Как сделать чтобы на странице выводились 2 разных значения meta_value' => '30' и предположим meta_value' => '40'
<?php
			$context          = array();
			$context['page'] = Timber::get_post();
			$args             = array(
				'post_type'   => 'tours_cat',
				'numberposts' => POSTS_PER_PAGE,
				'meta_key' => 'tour_type',
				'meta_value' => '30' // "1"
			);
			$context['posts'] = Timber::get_posts( $args );
			Timber::render( 'tours/tours.twig', $context );
			?>
  • Вопрос задан
  • 71 просмотр
Решения вопроса 1
deniscopro
@deniscopro Куратор тега WordPress
WordPress-разработчик, denisco.pro
<?php
	$context          = array();
	$context['page'] = Timber::get_post();
	$args             = array(
		'post_type'   => 'tours_cat',
		'numberposts' => POSTS_PER_PAGE,
		'meta_query' => array(
			'relation' => 'OR',
			array(
				'key'     => 'tour_type',
				'value'   => '40',
			),
			array(
				'key'     => 'tour_type',
				'value'   => '30',
			),
		),
	);
	$context['posts'] = Timber::get_posts( $args );
	Timber::render( 'tours/tours.twig', $context );
?>
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы