Setting custom links for the featured pages in Customizr

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

By default, Customizr links to the page you have choosen in the dropdown list (see the featured pages documentation)  . You can easily change this with the following snippet.

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

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

 

add_filter('tc_fp_link_url' , 'my_custom_fp_links', 10 );
//If you are using the featured pages Unlimited Plugin or the Customizr Pro theme, uncomment this line :
//add_filter('fpc_link_url' , 'my_custom_fp_links', 10 );

function my_custom_fp_links( $original_link ) {

    //assigns a custom link by page id
    $custom_link = array(
        //page id => 'Custom link'
        2 => 'http://www.my-custom-url-one.com',
        9 => 'http://www.my-custom-url-two.com'
    );

    foreach ($custom_link as $page_id => $link) {
        if ( get_permalink($page_id) == $original_link )
            return $link;
    }

    //if no custom title is defined for the current page id, return original
    return $original_link;
}

 

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.

71 thoughts on “Setting custom links for the featured pages in Customizr”

Comments are closed.