Leo[nardo] Germani
Page Templates ou Custom Rewrite Rules
pre_get_posts() e WP_Query
add_action('pre_get_posts', function($query) {
if ($query->is_post_type_archive('project') && $query->is_main_query()) {
$query->set('orderby', 'meta_value_num');
$query->set('meta_key', 'numero');
$query->set('order', 'ASC');
}
});
add_action('pre_get_posts', function($query) {
if ($query->is_post_type_archive('filmes') && $query->is_main_query()) {
$query->set('posts_per_page', -1);
$query->set('orderby', 'title');
$query->set('order', 'ASC');
}
});
<?php
$sections = new WP_Query(
array(
'post_type' => 'filmes',
'post_parent' => get_the_ID(),
'ignore_sticky_posts' => true,
'showposts' => -1,
'orderby' => 'title',
'order' => 'ASC'
)
);
?>
<?php if ($sections->have_posts()): ?>
<?php while ($sections->have_posts()): $sections->the_post(); ?>
<?php the_title(); ?>
...
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
Adoraria ajudar com alguns casos concretos
leogermani@hacklab.com.br
github.com/leogermani/apresentacao-planejando-projeto-wp