Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ваш вариант:
- <?php
- $sw_args = array(
- 'post_type' => 'films',
- 'meta_query' => array(
- array(
- ------------'key' => 'ТУТ ЗНАЧЕНИЕ ПРОИЗВОЛЬНОГО ПОЛЯ В ЗАВИСИМОСТИ ОТ СТРАНИЦЫ, ОНО ДОЛЖНО МЕНЯТЬСЯ',---------------
- 'value' => array( 'George Lucas', 'Richard Marquand', 'Irvin Kershner' ),
- 'compare' => 'IN',
- )
- )
- );
- $query = new WP_Query( $sw_args );
- if ( $the_query->have_posts() ) {
- echo '<h2>Films By Star Wards Directors</h2>';
- echo '<ul>';
- while ( $the_query->have_posts() ) {
- $the_query->the_post();
- echo '<li>' . get_the_title() . '</li>';
- }
- echo '</ul>';
- }
- /* Restore original Post Data */
- wp_reset_postdata();
- ------------------------------------------------
- Используемый мной вариант:
- Здесь, я хотел бы сделать динамическим значение 'cat' => 210,
- Чтобы значение 'cat' принимало значение произвольного поля
- <?php
- $args = array('cat' => 210, 'posts_per_page' => 5, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC' );
- query_posts($args);
- while ( have_posts() ) : the_post();
- ?>
- ---- Вывод заголовка
- ---- Вывод миниатюры и краткой записи
- <?php endwhile; wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement