Advertisement
artemsemkin

Extend "Homepage displays" dropdown in admin panel

Sep 28th, 2022
1,891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Extend "Homepage displays" dropdown in admin panel
  5.  */
  6. function add_pages_to_dropdown( $pages, $r ) {
  7.   if ( ! isset( $r['name'] ) ) {
  8.     return $pages;
  9.   }
  10.  
  11.   if ( 'page_on_front' === $r['name'] ) {
  12.     $args = array(
  13.       'post_type'      => 'arts_portfolio_item',
  14.       'posts_per_page' => -1,
  15.     );
  16.  
  17.     $portfolios = get_posts( $args );
  18.     $pages      = array_merge( $pages, $portfolios );
  19.   }
  20.  
  21.   return $pages;
  22. }
  23. add_filter( 'get_pages', 'add_pages_to_dropdown', 10, 2 );
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement