Advertisement
VictorMisa

mostrar un grid con las páginas hijo y hermanas en gutenberg

Sep 27th, 2022
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #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 😉
  2.  
  3. By isaac delgado
  4.  
  5. function filter_post_query( $query_args, $attributes) {
  6.  
  7. // Modify $query_args values.
  8. global $post;
  9.  
  10. $current = $post->ID;
  11. $parent = $post->post_parent;
  12. if($current == "0"){
  13. // $post->ID is id of current page.
  14. $query_args = array(
  15. 'post_type' => 'page',
  16. 'post_parent' => $post->ID,
  17. );
  18. } else{
  19. $query_args = array(
  20. 'post_type' => 'page',
  21. 'post_parent' => $post->post_parent,
  22. 'post__not_in' => array( $post->ID ), //excluye el post actual
  23. );
  24. }
  25. return $query_args;
  26.  
  27. }
  28. add_filter( 'uagb_post_query_args_grid', 'filter_post_query', 10, 2 );
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement