我从不同的页面上得到一些图片,它们有一个特殊的父页面。
$query = new WP_Query(
array(
\'post_type\' => \'page\',
\'post_parent__in\' => array(376, 379),
\'orderby\' => \'title\',
\'order\' => ASC,
\'posts_per_page\' => 9999
)
);
但现在,我希望代码不仅查找父页面,还查找单个页面。是否可以合并
post_parent__in
&;
post__in
?
$query = new WP_Query(
array(
\'post_type\' => \'page\',
\'post_parent__in\' => array(376, 379),
\'post__in\' => array(1148),
\'orderby\' => \'title\',
\'order\' => ASC,
\'posts_per_page\' => 9999
)
);
如果我使用第二个代码,它不会显示任何内容。它应该查找具有父页面或特定页面id的图像。
谢谢你的帮助
短代码:
function galerie_klassisch_wohnen() {
$query = new WP_Query(
array(
\'post_type\' => \'page\',
\'post_parent__in\' => array(376, 379, 382),
\'orderby\' => \'title\',
\'order\' => ASC,
\'posts_per_page\' => 9999
)
);
if ( $query->have_posts() ) : while($query->have_posts()) : $query->the_post();
$return_string .= \'<div class="dynamische-galerie"><div class="col-3"><div class="dynamische-galerie-wrapper"><a href="\'.get_permalink().\'">\'.get_the_post_thumbnail( $post_id, array(285,200) ).\'</a><div class="dynamische-galerie-caption"><a href="\'.get_permalink().\'"><b>\'.get_the_title().\'</b><br>\'.number_format(get_field( \'nettogrundflaeche\' ),2,\',\',\'.\').\'<span> m²</span></a></div></div></div></div>\';
endwhile;
return $return_string;
endif;
wp_reset_postdata();
}
add_shortcode( \'galerie_klassisch_wohnen\', \'galerie_klassisch_wohnen\' );