WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#35416 new enhancement

List children pages of another (in dashboard)

Reported by: selnomeria Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: ui, administration Cc:
PR Number:

Description

In Dashboard, in "ALL POSTS" page,
there is available to list POSTS of specific categories..

it is good, if such thing was possible for PAGES,
when i have hundreds of pages, then i want to show only specific page's children pages...

please add this posibility (like url :

/wp-admin/edit.php?parent=2754&post_status=all..................

Attachments (3)

35416.diff (2.6 KB) - added by Shital Patel 4 months ago.
Sorting Pages by parent
patch_for_page_sort_parent.diff (2.6 KB) - added by tazotodua 4 months ago.
35416-2.diff (2.6 KB) - added by tazotodua 4 months ago.

Download all attachments as: .zip

Change History (12)

#1 @swissspidy
4 years ago

  • Component changed from General to Posts, Post Types
  • Focuses ui administration added

#2 @DrewAPicture
2 years ago

Hi @selnomeria, are you saying that you want to add something like parent=### support to the posts list table (used for all post types)? If so, would you be interested in submitting a patch?

#3 @tazotodua
2 years ago

(I am OP selnomeria.. it was my old user).

here is solution.
it's good if you added as a patch, because i am not familiar with adding patch in core myself...

add_action('init', 'parented_posts_initialize',11);
function parented_posts_initialize(){
	$p_types = array('post','page'); //get_post_types()
	$parented_post_types = apply_filters('parented_posts_filter',$p_types );
	foreach($parented_post_types as $each){
		add_filter('manage_edit-'.$each.'_columns', 'create_parented_column');
		add_action('manage_'.$each.'_posts_custom_column', 'parented_column_func', 10, 2 );
		add_filter('manage_edit-'.$each.'_sortable_columns', 'make_parent_column_sortable' );
	}
}

function create_parented_column($columns) {
    $columns['parents'] =__('parents');
    return $columns;
}

function parented_column_func( $column_name, $post_id ) {
    if ( 'parents' != $column_name )        return;
    //Get number of parents from post meta
    $parentId = wp_get_post_parent_id( $post_id ) ;
	$parent_p= get_post($parentId);
	if($parentId != $post_id && $parentId !=0){
		$url =  $_SERVER['REQUEST_URI'];
		$url =  add_query_arg('parent_id', $parentId, $url );
		$url =  add_query_arg('orderby', 'parent', $url );
		echo '<a href="'.$url.'">'.$parent_p->post_name.'</a>'; return;
	}
    echo ($finalParent);
}	

function make_parent_column_sortable( $columns ) {
    $columns['parents'] = 'parent';   // to remove:  unset($columns['date']);
    return $columns;
}

add_action( 'pre_get_posts', 'my_slice_orderby' );
function my_slice_orderby( $query ) {
    if( ! is_admin() )          return;
	global $pagenow;
	if ( ( $pagenow == 'edit.php' ) ) {     // && ( 'slices' == $query->get( 'orderby'))
		if(isset($_GET['parent_id'])){
			$query->set('post_parent', (int) $_GET['parent_id'] );
		}
	}
}

user can use filter to add his desirable custom filter:

add_filter('parented_posts_filter', 'myparented_fitlers',10,1);
function myparented_fitlers($post_types=array()){
	return array_merge($post_types, array('my_custom_type') );
}
	
Last edited 2 years ago by tazotodua (previous) (diff)

#4 @kpegoraro
2 years ago

Yes, we have had this business request, too. One thing that has helped us without this core functionality is to use this CMS Tree Page View plugin: http://eskapism.se/wordpress/cms-tree-page-view/. Is that similar to what you wanted, maybe in a different way?

#5 @tazotodua
2 years ago

@kpegoraro I think that solution should be even included in CORE! that will take WP administration of pages/posts into the higher stage.

#6 @SergeyBiryukov
4 months ago

#47739 was marked as a duplicate.

@Shital Patel
4 months ago

Sorting Pages by parent

#7 @tazotodua
4 months ago

I am re-posting from this another topic (which was closed as duplicate for this topic), so I am attaching my patch here (@shital-patel seems you copied my attached patch, thanks, but I have modified it again as Sergey suggested in that topic), and I am also adding screenshots:

Here screenshot -
left side is original, clicking on the parent slug makes the table sorted (as on the right screenshot)

https://i.imgur.com/FFfosWn.png

The attached patch is just my approximation, but I doubt that it will need some modification or revision, because I've added "post_parent" in public_query_vars

Last edited 4 months ago by tazotodua (previous) (diff)

@tazotodua
4 months ago

#8 @tazotodua
4 months ago

@swissspidy @DrewAPicture , now, the patch is added.

Version 0, edited 4 months ago by tazotodua (next)

#9 @tazotodua
4 months ago

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.