Setting custom titles for the featured pages

There are cases when you need to set a custom titles for the featured pages displayed on front page.

By default, Customizr uses the titles that you have defined for your pages. You can easily change this with the following snippet.

1) Grab the page’s id for which you need to set this custom title (how to get a page’s id?)

2) Assign a custom title by page id in the $custom_title  array below (I have set examples but you’ll need to change the id and custom titles values)

 

add_filter('tc_fp_title' , 'my_custom_fp_titles', 10 ,3);
function my_custom_fp_titles( $original_title , $fp_id = null , $page_id = null ) {
    
    //assigns a custom title by page id
    $custom_title = array(
        //page id => 'Custom title'
        2 => 'My custom title',
        9 => 'Title Example for page id #9'
    );
    
    //if no custom title is defined for the current page id, return original
    if ( ! isset($custom_title[$page_id]) )
        return $original_title;

    return $custom_title[$page_id];
}

Customzir-Pro or Featured Pages Unlimited user ? Use this code  (only the filter’s name is different)

add_filter('fpc_title' , 'my_custom_fp_titles', 10 ,3);
function my_custom_fp_titles( $original_title , $fp_id = null , $page_id = null ) {
    
    //assigns a custom title by page id
    $custom_title = array(
        //page id => 'Custom title'
        2 => 'My custom title',
        9 => 'Title Example for page id #9'
    );
    
    //if no custom title is defined for the current page id, return original
    if ( ! isset($custom_title[$page_id]) )
        return $original_title;

    return $custom_title[$page_id];
}

 

 

Where to paste this code? => in your functions.php file. I strongly recommend to create a child theme. Download a start-up child theme here.

Everything you need to know about child theme with Customizr here.

30 thoughts on “Setting custom titles for the featured pages”

Comments are closed.