Backpress Wordpress Pages, Filtered Meta List

I am trying to do something with Wordpress. I want to use it pageas a wrapper for custom content, so I set up an action that adds a specific one meta_keyfor each regular page so that I can select regular pages from my "special pages".

function addMetaToPage($post_id) {
  if ( wp_is_post_revision( $post_id ) )
    return;

  if(get_post_type($post_id) == 'page') {
    add_post_meta($post_id, '_regular_page', 1, true);
  }
}

if(is_admin()) {
  add_action('save_post', 'addMetaToPage');
}

Then, in the admin backend, where the pages are listed, I launch this hook so that all my "special pages" are not displayed.

if(is_admin()) {
  add_action('pre_get_posts', function($query) {
    $query->set('meta_key', '_regular_page');
    $query->set('meta_value', 1);
  });
}

. meta _regular_page === 1. , , , All (15), , . . 4 6 , - _regular_page.

? , WP_Query, , -, .

+3
1

ALL, Published trash , views_edit-page   -

 add_filter( "views_edit-page", "filter_regular_page_count", 10, 1); 

 function filter_regular_page_count( $views ) {
     $regular_post_count = 5 ;// you can sort out how to get your regular post count

        $views["all"] = '<a href="edit.php?post_type=page" class="current">All <span class="count">('.$regular_post_count.')</span></a>';

//           return $views;
   }

var dump

array (size=3)
  'all' => string '<a href='edit.php?post_type=page' class="current">All <span class="count">(7)</span></a>' (length=88)
  'publish' => string '<a href='edit.php?post_status=publish&amp;post_type=page'>Published <span class="count">(7)</span></a>' (length=102)
  'trash' => string '<a href='edit.php?post_status=trash&amp;post_type=page'>Trash <span class="count">(2)</span></a>' (length=96)

, WordPress views_edit-post

wordpress - views --- > views_{$this->screen->id}

0

All Articles