Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Show only children of certain page on edit-pages.php WordPress



On wp-admin/edit-pages.php I need to show only those pages, that are children of page id N.

I thought that filter on edit-pages.php line 132 should do the trick:
$query = apply_filters('manage_pages_query', $query);
But i'm stuck with it's strange behavior:
it works fine with 'posts_per_page'=>n
but it ignores 'post_parent'=>n

Could anyone point out what i am missing here?

UPDATE: i managed to get the wanted result by using "posts_where_request" filter in query.php, bud i'd still prefer something that is in edit-pages.php (filter or action).

Answers (2)


Buzu B answers:

an easy way to do it, though it doesn't use filters, is to use an if() to unset elements of $posts if they do not match our criteria. I have this:

foreach($posts as $post=>$value){
if($value->post_parent != 2){

and does the job; it shows only those pages whose parent id is 2. In order for this fix to work you need to find the line that reads:

<?php if ($posts) { ?>

on your edit-pages.php file, and modify the if() statement according to your needs. The line you will have to modify is on line 186, at least that is on my edit-pages.php file, but it might be different on yours because my wp instalation is a bit old. (need to update, I know.)

If your really, really need it to be using filters, let me know, we can look further into it.

Valentinas Bakaitis comments:

This is interesting idea, but I need to achieve the result without editing core files. So i need to use either filter or action hook.

Buzu B comments:

Ok, I have been playing around with some values and filters. Finally I came up with a piece of code that does what you need using a filter. Now, before we proceed, I would like to say that I think this answer is worth more than 10 bucks, but I leave it to you to decide, the answer is there anyways.

I also want to point out that this is more a hack than a correct use of the filter I'm using here. In other words, I'm using ( and maybe abusing) a filter that has a different purpose to accomplish your goal.

Here is the code, I currently have it placed in functions.php on my current themes folder, where is where you should place it just to stick to wp specification and development recommendations.

add_filter('manage_pages_columns', 'scompt_custom_columns');
function scompt_custom_columns($defaults) {
global $posts;
foreach($posts as $post=>$value){
if($value->post_parent != 2){
return $defaults;

I repeat, this solution is using a filter whose purpose is not to modify the list of pages in the edit section. I actually don't think there is a filter to do just that.

Valentinas Bakaitis comments:

Thanks for info. Unfortunately i can't spend much on this, but I'll rise it to $20.

Best of luck!


Brian Richards answers:

Is there a reason you're restricting the page listing by modifying core? If you're only looking to restrict what a user has access to editing, I HIGHLY recommend wp-role-scoper. It gives you very fine-tuned controls as to which pages, posts, categories, etc a user can see and which ones they can edit. Furthermore, it let's you set this access level both user-by-user an by group as well (you can create as many user groups as you like).

I used it on [[LINK href=""]][[/LINK]] to only allow regional editors to have access to their region and no others, and then again so that regional contributors could only suggest new/revised content without actually publishing anything.

Hope this helps!

Valentinas Bakaitis comments:

Just to be clear: I'm not modifying any core files, those filters I mentioned above are wordpress core filters, not mine. I'm just looking for a filter, that could give me control over the query, that fetches all pages for editing.

Currently I am using a filter, which is located at query.php, but as you can guess this filter is applied to all queries, and i would like to use the filter, that is applied only to the query that fetches pages for editing.

Thanks for the plug-in, but I am looking only for a filter (or action hook?), which is a lot simpler solution in my case.

Brian Richards comments:

Ah, got it. Unfortunately I am not a filter/action guru so I can be of no more service. Best of luck!