Created
January 30, 2013 14:51
-
-
Save seebz/4673786 to your computer and use it in GitHub Desktop.
Titre des archives CTP disposant d'une page WP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Titre des archives CTP disposant d'une page WP | |
| */ | |
| add_filter('post_type_archive_title', 'fhp_post_type_archive_title'); | |
| function fhp_post_type_archive_title($title) | |
| { | |
| $post_type = get_query_var('post_type') | |
| or $post_type = get_post_type(); | |
| $post_type_object = get_post_type_object($post_type); | |
| if ( ! $post_type_object->_builtin) | |
| { | |
| $archive_link = get_post_type_archive_link( $post_type ); | |
| $archive_path = trim( str_replace(home_url(), '', $archive_link) ); | |
| $archive_page = get_page_by_path($archive_path); | |
| if ($archive_page) | |
| { | |
| $title = apply_filters( 'the_title', $archive_page->post_title, $archive_page->ID ); | |
| } | |
| } | |
| return $title; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment