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

WordPress Trac noreply at wordpress.org
Thu Apr 6 14:21:10 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
-------------------------------------------------+-------------------------

Comment (by joysons):

 I can understand the issue you are facing with the get_pages() function
 and the modifications that have been made to it. It is always important to
 ensure that the code works as intended, and I appreciate your efforts to
 identify and address this issue.

 It seems that your previous workaround involved using the apply_filters()
 hook to filter pages per language and passing the language as an argument
 to get_pages() using the 'lang' parameter. However, with the new method
 using WP_Query, sorting by language when a language is passed as an
 argument is no longer functioning as expected.
 To resolve this issue, there are a couple of possible solutions that you
 can consider. One solution is to carry the arguments received by
 get_pages() to the WP_Query. This can be done by modifying the WP_Query
 arguments array to include the 'lang' parameter that was previously passed
 to get_pages(). This will ensure that the pages are filtered by the
 language passed in the argument and not the current language. Another
 solution is to add a filter to filter the $query_args (with the
 $parsed_args). This will allow you to modify the WP_Query arguments and
 include the 'lang' parameter that was previously passed to get_pages().
 This filter can be added to the apply_filters() hook that you were
 previously using to filter pages per language
 [https://strictednewsone.blogspot.com/ .] Both of these solutions should
 help to resolve the regression you are experiencing and ensure that your
 code works as intended. It is important to thoroughly test any changes
 made to the code to ensure that they do not cause any other regressions or
 issues. Additionally, it may be helpful to consider the broader context of
 the modifications made to get_pages(). The modifications may have been
 made for a reason, such as to improve performance or functionality. It may
 be worth discussing these changes with the developers who made them to
 ensure that any changes made to your code do not conflict with the broader
 goals of the project.

 In conclusion, I hope that these suggestions help to resolve the issue you
 are experiencing with the get_pages() function. It is always important to
 ensure that the code works as intended and to be diligent in identifying
 and addressing any regressions or issues.

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


More information about the wp-trac mailing list