astra_breadcrumb_get_parents( int $post_id = '', string $delimiter = '/' )
Gets parent pages of any post type.
Description
Parameters
- $post_id
-
(int) (Optional) ID of the post whose parents we want.
Default value: ''
- $delimiter
-
(string) (Optional) .
Default value: '/'
Return
(string) $html String of parent page links.
Source
File: addons/advanced-headers/classes/astra-breadcrumbs.php
function astra_breadcrumb_get_parents( $post_id = '', $delimiter = '/' ) { $parents = array(); if ( 0 == $post_id ) { return $parents; } while ( $post_id ) { $page = get_page( $post_id ); $parents[] = '<span class="ast-breadcrumbs-link-wrap" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a itemprop="item" rel="v:url" property="v:title" href="' . esc_url( get_permalink( $post_id ) ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '"><span itemprop="name">' . get_the_title( $post_id ) . '</span> <meta itemprop="position" content="${content}"/> </a></span>'; $post_id = $page->post_parent; } if ( $parents ) { $parents = array_reverse( $parents ); } return $parents; }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |