Get top parent category

get_ancestors() returns an array containing the parents of any given object.

This example has two categories. The parent with the id of 447 and the child with a id of 448 and returns the a category hierarchy (with IDs):

get_ancestors( 448, 'category' ); 

returns:

Array
(
    [0] => 447
) 

get_ancestors Codex Page

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)