PHPackages                             cnp/wp-highest-ancestor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cnp/wp-highest-ancestor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cnp/wp-highest-ancestor
=======================

A function for getting information about the highest ancestor of a post or term. Useful for section title information.

v0.2.3(9y ago)085[1 issues](https://github.com/Clark-Nikdel-Powell/WP-Highest-Ancestor/issues)MITPHPPHP &gt;=5.3.3

Since Nov 5Pushed 9y ago2 watchersCompare

[ Source](https://github.com/Clark-Nikdel-Powell/WP-Highest-Ancestor)[ Packagist](https://packagist.org/packages/cnp/wp-highest-ancestor)[ Docs](https://github.com/Clark-Nikdel-Powell/WP-Highest-Ancestor)[ RSS](/packages/cnp-wp-highest-ancestor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (10)Used By (0)

Section Information
-------------------

[](#section-information)

This function returns section information, which varies depending on the type of page you're viewing. Several conditional checks are combined into this one function so that you can get comprehensive section data form one function, rather than an exhaustive list of conditional statements.

It supports custom post type pages: e.g., if you have a CPT of "movies," creating a page with the slug of "movies" will return data from the page, rather than data from the post type object. This is useful for keeping complicated post type archive content in the CMS.

### Parameters

[](#parameters)

`check_for_page`: Whether to check for a page with a matching slug when on a post type/taxonomy archive/single. Will also perform the check for pages with a slug of 'search' and '404'. Default 'true'.

`post_type_pages`: The function will default to the name of the post type for post type page checks, but you can manually override it with this parameter. Includes defaults for Search and 404.

### Returns

[](#returns)

```
$ancestor = array(
	'id'          => Ancestor ID,
	'title'       => Ancestor title,
	'name'        => Ancestor slug,
	'object'      => Ancestor post/term object,
	'found_posts' => Conditional. Number of search results
);

```

### Filters

[](#filters)

You can adjust the output of this function by adding this filter: `add_filter( 'cnp_get_highest_ancestor', 'custom_filter_title', 20, 1 )`. The accepted argument is the `ancestor` variable. Return it in your filter function to alter the output.

### Scenarios

[](#scenarios)

#### Hierarchical post type (*is\_post\_type\_hierarchical*)

[](#hierarchical-post-type-is_post_type_hierarchical)

Returns data about the highest ancestor of the current post. If the current post is a top-level post, then the current post data is returned.

#### Flat post type (else)

[](#flat-post-type-else)

Returns data about the post type. Will check for a page with the same slug as the post type if `$args['check\_for\_page']` is true, returns basic post type data otherwise.

#### Default home page (*is\_home* &amp;&amp; *is\_front\_page*)

[](#default-home-page-is_home--is_front_page)

Returns basic home page data.

#### Static Front Page (*page\_on\_front*)

[](#static-front-page-page_on_front)

Returns data based on the Front Page post object, which is defined in the Reading Settings.

#### Posts Page (*page\_for\_posts*)

[](#posts-page-page_for_posts)

Returns data based on the Posts Page, which is defined in the Reading Settings.

#### Taxonomy Terms (*is\_tax, is\_category, is\_tag*)

[](#taxonomy-terms-is_tax-is_category-is_tag)

Returns data based on the current taxonomy term.

#### Search Results (*is\_search*)

[](#search-results-is_search)

Returns basic search results data.

#### 404 Page (*is\_404*)

[](#404-page-is_404)

Returns basic 404 page data.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~44 days

Recently: every ~26 days

Total

8

Last Release

3531d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7df60fcdb3fa310756e7ba0e801c8f311e4edf53111a8d09895ead3652fb76a9?d=identicon)[cnp](/maintainers/cnp)

---

Top Contributors

[![jhned](https://avatars.githubusercontent.com/u/2520143?v=4)](https://github.com/jhned "jhned (16 commits)")[![gwelser](https://avatars.githubusercontent.com/u/2042739?v=4)](https://github.com/gwelser "gwelser (2 commits)")

### Embed Badge

![Health badge](/badges/cnp-wp-highest-ancestor/health.svg)

```
[![Health](https://phpackages.com/badges/cnp-wp-highest-ancestor/health.svg)](https://phpackages.com/packages/cnp-wp-highest-ancestor)
```

###  Alternatives

[cubear/finder

Finder is a Drupal 8 module to help users find services which meet their criteria

404.2k](/packages/cubear-finder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
