dc crage
dc crage

Reputation: 1

How to create a filter hook that will change the page title in WordPress

I'm attempting to write a filter that changes the page title from a h5 to a h1.  Here's an excerpt of the parent theme function that I'm attempting to change:

function constico_site_breadcrumbs() {

$breadcrumbs_settings = apply_filters( 'constico_breadcrumbs_settings', array(
    'wrapper_format'    => '<div class="container"><div class="row">%1$s<div class="breadcrumbs__items">%2$s</div></div></div>',
    'page_title_format' => '<div class="breadcrumbs__title"><h5 class="page-title">%s</h5></div>',// trying to change this into h1
    'separator'         => '&#47;',
    'show_title'        => $breadcrumbs_page_title,
    'path_type'         => $breadcrumbs_path_type,

I tried copying the entire function into the filter hook with changes, but it produced errors.

function tt_seopagetitle() { // function with changes } add_filter('constico_breadcrumbs_settings','tt_seopagetitle'); guidance will be much appreciated!

Upvotes: 0

Views: 475

Answers (1)

Moshe Gross
Moshe Gross

Reputation: 1395

You can overwrite just the page_title_format like this

function tt_seopagetitle($title){
    $title['page_title_format'] = '<div class="breadcrumbs__title"><h1 class="page-title">%s</h1></div>';
    return $title;
}

add_filter('constico_breadcrumbs_settings', 'tt_seopagetitle', 10)

Upvotes: 1

Related Questions