[wp-trac] [WordPress Trac] #12821: Merge get_posts() and get_pages()

WordPress Trac noreply at wordpress.org
Thu Apr 6 11:53:31 UTC 2023


#12821: Merge get_posts() and get_pages()
-------------------------------------------------+-------------------------
 Reporter:  mikeschinkel                         |       Owner:
                                                 |  spacedmonkey
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.3
Component:  Posts, Post Types                    |     Version:  3.0
 Severity:  normal                               |  Resolution:
 Keywords:  needs-dev-note has-patch has-unit-   |     Focuses:
  tests needs-testing dev-feedback commit        |  performance
-------------------------------------------------+-------------------------
Changes (by marianne38):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 Hi,

 The way {{{get_pages()}}} has been modified leads to a regression on our
 side.

 With the previous method, we used a workaround by hooking on this filter :
  {{{apply_filters( 'get_pages', $pages, $parsed_args )}}}
 to filter the pages per language, see
 [https://github.com/polylang/polylang/blob/3.3.2/include/filters.php#L193]

 We used to pass the language to {{{get_pages()}}} in the arguments like
 this :
  {{{get_pages( array( 'lang' => 'en' ) )}}}.

 We pass a taxonomy on the pages for the languages.
 This new method with the {{{WP_Query}}} breaks the sorting of the pages by
 language when a language is passed as argument.

 Because we filter the {{{WP_Query}}} requests by the current language,
 however if we add a {{{'lang'}}} argument to {{{get_pages()}}}, we have to
 filter the pages by the language passed in argument and not the current
 one.

 So it would be useful to carry the arguments received by {{{get_pages()}}}
 to the {{{WP_Query}}}, or to add a filter to filter the {{{$query_args}}}
 (with the {{{$parsed_args}}}).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/12821#comment:78>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list