Hi,
I have the following code that displays “All Jobs”, “All Jobs Page 2”, on the home page and paginated pages.
I’d like to set the “All Jobs” on the homepage to an H2 tag since I already have an H1. Using H1 on the paginated/archive pages works since it is the only H1 tag on those pages. Can you please help with this?
// job opening archive title
add_filter( 'get_the_archive_title', function( $title ) {
if(is_post_type_archive('job-opening')) {
the_post();
//global $page;
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$title = sprintf('All Jobs - Page %1$s', $paged);
rewind_posts();
}
return $title;
} );
// front page job opening archive title
add_filter( 'render_block', function( $block_content, $block ) {
if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'my-blog-title' ) !== false && is_paged() ) {
$myreplace1 = 'All Jobs';
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$myinsert1 = sprintf('All Jobs - Page %1$s', $paged);
$block_content = str_replace( $myreplace1, $myinsert1 , $block_content );
}
return $block_content;
}, 10, 2 );