For anyone using All in one SEO plugin and registered the CPT's via PHP, here's what you can do.
In the CPT registration, inside the labels array, add;
'archive_seo_title' => 'your set title | your site',
'archive_meta_desc' => 'your meta description'
and then in your functions.php file add these 2 filters;
// CPT Archive page SEO Title
add_filter( 'aioseop_title', 'dd_rewrite_custom_titles' );
function dd_rewrite_custom_titles( $title ) {
if ( is_post_type_archive() ) {
$post_type = get_post_type_object( get_post_type() );
if ($post_type->labels->archive_seo_title){
$title = $post_type->labels->archive_seo_title;
}
}
return $title;
}
// CPT Archive page meta Description
add_filter( 'aioseop_description', 'filter_aioseop_description');
function filter_aioseop_description( $description ) {
if ( is_post_type_archive() ) {
$post_type = get_post_type_object( get_post_type() );
if ($post_type->labels->archive_meta_desc){
$description = $post_type->labels->archive_meta_desc;
}
}
return $description;
}
These filters will first check if the current page is a CPT archive and if it determines that it is, it will set the seo title and description to what you set in the labels array during CPT registration. If the filter does not detect a CPT archive page, then it will just return the original titles + description that is set by default.
Note: If you are not using CPT php registration, you can just make $title and $description variables equal to whatever you want, e.g.
$title = get_the_title() . ' | ' . get_bloginfo();
has_archive
set tofalse
? Also don't name custom page templates with names that clash with default template names in the template hierarchy./books/
and set your post type rewrite also tobooks
, there should be no conflict there as long as you sethas_archive
to false. you'd have to run a custom query in your page to reproduce the archive loop you'd get if you used the post type archive instead of a page. your other option is to just use the cpt archive WordPress generates and then filterwp_title
to set the title to whatever you want.