Skip to content

Instantly share code, notes, and snippets.

@seebz
Created January 30, 2013 14:51
Show Gist options
  • Select an option

  • Save seebz/4673786 to your computer and use it in GitHub Desktop.

Select an option

Save seebz/4673786 to your computer and use it in GitHub Desktop.
Titre des archives CTP disposant d'une page WP
<?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