Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #codigo Para los que queráis mostrar un grid con las páginas hijo y hermanas en gutenberg con Spectra (antes Ultimate addons for guttenberg de Astra), añadiendo este código en el functions mostrará automáticamente las páginas hija y en las hijas mostrará las hermanas cuando añadáis el bloque Post Grid a la página en cuestión 😉
- By isaac delgado
- function filter_post_query( $query_args, $attributes) {
- // Modify $query_args values.
- global $post;
- $current = $post->ID;
- $parent = $post->post_parent;
- if($current == "0"){
- // $post->ID is id of current page.
- $query_args = array(
- 'post_type' => 'page',
- 'post_parent' => $post->ID,
- );
- } else{
- $query_args = array(
- 'post_type' => 'page',
- 'post_parent' => $post->post_parent,
- 'post__not_in' => array( $post->ID ), //excluye el post actual
- );
- }
- return $query_args;
- }
- add_filter( 'uagb_post_query_args_grid', 'filter_post_query', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement