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.
72 thoughts on “Setting custom links for the featured pages in Customizr”
I know this is an old post, but I am wanting to do something similar with a current version of Customizr Pro and this code does not seem to be working for me. Does anyone know if this should be compatible with the current version of Customizr Pro? If not, any ideas on tweaking the code to make it compatible are greatly appreciated.
Hi Raquel,
This can be achieved through url redirection.
Hey Nicolas,
I’m not exactly familiar with coding, but I’m getting there. I’m trying to link the first feature page to a category page. This is pasted in the child. So 97 is the page I can link to in the options, and cat=4 is the category page I want it changed to. I’ve tried with the full link as well. Do you have a suggestion as to what I’m doing wrong?
Site is http://www.nativeamericanmuseum.org/
add_filter(‘tc_fp_link_url’ , ‘my_custom_fp_links’, 10,2);
function my_custom_fp_links( $original_link , $fp_id ) {
//assigns a custom link by page id
$custom_link = array(
//page id => ‘Custom link’
97=> ‘http://www.nativeamericanmuseum.org/?cat=4’
);
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;
}
Hi Amber, our developer team tries to handle technical requests for the Customizr free theme in the support forum, would you mind asking your question there ?
https://wordpress.org/support/theme/customizr
Thanks 🙂
Thanks,
I actually fixed it ^_^
<3
Hi Amber,
I have similar problem, I have two custom links I want to point to a category, I have the link but I don’t know what value am I suppose to use as page_id since I want to link to a category, for example to:
http://dogplanetweb.com/category/adopciones/perros-adopcion . How did u fix it?
Thank you so much!!!! Got it working. Very grateful!!!
Thanks!
Erin
I’m really struggling to make this code work on my site.
My site is located here: http://new.connectionsvolunteercenter.org/wp/
I’m trying to get the first featured page circle “Volunteer” to link to my subdomain here: http://volunteer.connectionsvolunteercenter.org/wp/
I’ve tried and tried to no avail. I’ve pasted the following into the functions.php file.
Any thoughts would greatly be appreciated! Thank you!
Hi Erin,
This filter requires two parameters to work properly, therefore when you declare it you need to use the following syntax:
Hope this helps !
Hello Erin,
in addition to what Nicolas said, since you use customizr-pro you should use, as written in the snippet:
`add_filter(‘fpc_link_url’ , ‘my_custom_fp_links’, 10 ,2);`
and not
`add_filter(‘tc_fp_link_url’ , ‘my_custom_fp_links’, 10 ,2);`
Hope this helps.
hi,
i cant seem to figure out what parts of the code to edit so that i wil link to a categorie. does anyone have a more detaild instruction on how to edit this code.
Hi, you might want to look at the guide to customize the Customizr theme.
If you still don’t find your way, please post a new topic in the support forum.
Bests 🙂
Yep this definitely doesn’t work for me now matter how I type it. Went through all the comments above. Not getting any errors, but nothing happens. Here’s my code:
Hi, your filter function doesn’t look to have the right syntax.
You might want to open a topic in the support forum about this : https://wordpress.org/support/theme/customizr
Thanks 🙂
Hello,
i have put the code you describe in your text and changed to my category id, and i get the following error in my site:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘my_custom_fp_links’ not found or invalid function name in /home/kanesbit/public_html/geekstuff/wp/wp-includes/plugin.php on line 213
i havent change any code in other files.
Thanks for your help.
Hi, the error message is saying that the function
my_custom_fp_links
has not been declared properly and you can’t use it as a callback for your WordPress action.Hope this helps 🙂
And please. What`s the code for the product_cat? Is the same?
Please I need your help !!!!!
I am a newbie, and just uploaded a child theme functions.php file in order to create a link from my home page to my YouTube channel.
I received this error:
Parse error: syntax error, unexpected ‘http’ (T_STRING), expecting ‘)’ in /home/content/p3nexnas05_data02/63/2125863/html/wp-content/themes/customizr-child/functions.php on line 11
I cannot access my website!
Thank you, for any assistance!
http://www.forrestproperties.com
so i added the above code.
the buttons on the front featured page don’t goto the urls i specified.
1) Grab the page’s id for which you need to set this custom link (how to get a page’s id in WordPress?)
am i suppose to use the ID of the page where i want to go when button is clicked?
When i goto customize, am i supppose to see something in the dropdown or will the front page just update itself with the links on the buttons
Hi,
1) this is the page id of the paged you display as featured page, not the target.
2) you won’t see anything different in the customizer, the snippet changes things on the live site only
Hope this helps, thanks
Hello everyone.
I would like to add custom urls to posts’ featured images of a specific category. I’ve done some research, I’ve added a custom field named ‘external_url’, but I don’t know where to put this code:
Does it go to the theme functions.php or somewhere else? Can anyone help me please?
Hi Marilena, it has to be inserted in the functions.php or your theme or child theme.
More about how to customize the Customizr theme here.
Hi – I was reading this post as I was trying to modify the featured pages on the homepage of my customizr theme to display categories. I pasted the code into the functions.php file under editor and my page is now crashed. I keep receiving an error saying the following:
Parse error: syntax error, unexpected ‘=’ in /home/content/p3pnexwpnas01_data01/11/2223211/html/wp-content/themes/customizr/functions.php on line 61
I’m not unable to edit anything through my admin account and cannot view the website externally as well. Is there any guidance you can provide on how to fix this?
Thanks,
Eric
I added the code to make one of the featured links go to our Instagram page.
My question is…..what can I add to the snippet code to make it open a new window?
Hi, to open a link in a new tab, you need to add the following attribute inside the tag : target=”_blank”.
Hope this helps!
I have tried adding (target”_blank”) after the link, but get a parse error.
I have no clue what so ever why this isnt working
I have a child theme in place, and in that folder, and yes it is currently installed and active… all I have is the style.css and the functions.php
this is what I have in my functions, and if you go to my site, you will see none of the links are working at all
bloodeagle.net
but if I mess up the code just a smidge, I get errors, so I know it is loading from this functions.php
why isnt a single link working?
Amber,
Mine wasn’t working either until I changed the page id numbers on the left side of the code and on the first line in the code (in the code it is in black font, before the green link and on the first line – mine were 18, 25, 20). The black page id numbers need to correspond to the original pages’ id number (this is in your Theme>Customize>Content>Front Page>Featured pages options>Home featured page one…two…three pages). So, they are not the same as the page id number of your pages or categories that you are linking the new page in the green font (mine were 11,12,13). The pages you linked in the Theme>Customize…will only show up if there is a problem with the code. Otherwise, they will link to the green links as the featured page.
I don’t know if that makes sense, but here is my version from my code:
It seems that in my code I just wrote the “black” numbers I mentioned are coming up in red. Hope it helps.
Hello – I am using the customizr theme to update a current website. I have tried implementing the above php to set a different destination url for the featured image, however it is not working. I’ve changed the appropriate page ids and links but still it’s defaulting to the “feature one” page that I used as a test.
the site is live — http://macrodiver.com
thanks for any help getting this resolved.
Will this allow me to set the featured page to an external link? If so how do I get the “ID” for the external link?
Hi Jake,
It’s explained here : http://www.youtube.com/watch?v=fLg2T1AvmFE
Best
Hi Nicholas,
I have no coding knowledge at all and currently facing a problem, on how to link a category- called ‘Journal’ (blog posts) as a feature page 2 in my home page. How to change the default settings? I have read the above similar response, but have no clue as to how to do it step by step. Please help me , you can go to allylew.com
Thanks Nicholas!
Hi Ally, this snippet has to be pasted in functions.php of your theme or child theme.
You need to have some basic knowledges of PHP to do it.
Cheers
Is there any way to add a link in the right sidebar that will take the user back to the Front Page of customizr theme? I know they can like on the title at the top but I would also like to add it to the nav menu in the sidebar.
Hi Rhonda,
I would create a new menu in admin and include the home page in it. Then add this menu to the WP menu widget and assign this widget to the wanted sidebar location.
Hope this helps
Can i have featured page option in pages other than the home page?
This currrently requires some advanced coding but will be much implemented soon both in the new version of the theme and in the Featured Pages Unlimited plugin.
Best
hi Nicolas,
Is the option to use featured pages on other pages, so not just homepage, available in the paid plug-in now? Just want to check before I purchase. Thanks, Tina
Hi Tina,
There’s a simple code snippet to do it here : http://www.presscustomizr.com/snippet/featuring-pages-another-page-post-home/
Hope this will help!
Nicolas
Hi,
Is there any way to do the same thing for posts? I mean, when viewing a list of posts in a category page, I want to open a pdf file when clicking on a post. I already tried
xxx => ‘http://mysite.com/yyy.pdf’,
where the xxx is the page id of the post,
but with no result at all.
Best,
George
Isn’t there any solution for this?
Hi, I would recommend to use a post meta field to enter the url of the PDF.
Then on your post list, instead of calling the get_permalink() function, use the get_post_meta() function.
A good plugin to do this is Advanced Customi Fields.
Hope this will help!
Thanks Nicolas, I’ll try it. There is no simpler solution 🙁
Hi Nicolas,
I’ve been trying to get HTML links to work in the three featured text areas on this site http://www.strandvilla.se/ for about a week and then came across this solution, so I’m trying to link the read more buttons to the URL’s they should match too, these links shouldn’t change.
I added this code below to functions.php hoping it would help but it doesn’t seem to have come into effect, is there anything else I need to do?
Thanks,
Brizzle
Hey Brizzle,
Your code looks fine, it seems to work now?
What a beautiful work you did on your website!
You did really great, I would love to present your website in the Customizr showcase, feel free to submit it!
http://www.presscustomizr.com/showcase
Best regards,
Nicolas
Bon jour, Nicolas… I am trying your beautiful theme but i have this strange behaviour occuring when I open a category from the menu (I.e. the “Blog” cat.):
The title reads as this: Archivo Categorías: %s Blog (note the offending “%s” before the category name…)
Tried on the permalinks side but did not find any anomalies, at least that I can see.
What could I possibly be doing wrong?
Besides that, thank you for an awesome theme!
Is there any way to open the new page on a new tab? Thank you!
Hi Aniol, as of now there’s no easy way to do this but this is a good point and I’ll work on a solution for this.
Best regards
Ok, let me know if you solve it. Thank you!
I cannot get the featured pages feature to work. Wish I could post a screen shot….In the CustomizIt menu, I have it enabled and there are 3 home page featured pages listed that seem to be hyperlinks but nothing happens when I click on them. How do I set the 3 featured pages and their images? Either the documentation is not descript enough or my Theme is broken. Please help!
Hi Lena,
The first step is to choose the pages in the dropdown list. Then the links, content and thumbnails are set automatically.
Hope this helps!
http://www.presscustomizr.com/customizr/#homepage
Hi,
I need to implement this custom links for the featured pages but I’m very newbie on Wordpress 🙁 . I’m trying to do it but nothing changes.
Do I only need to change that number 2, 9 instead of my page ids? In fact, I need to use product url..
Do I also need to change the numbers of the first line 10 ,2?
For example, I have 3 featured pages and I need the second one is linked to “http://www.mysite.com/?product=box-1” How can I do that?
Thanks!
Can this snippet be used to link to an external page? Or does it only link to posts within one’s own WP site?
Hi Thomas, you can use either internal or external links as custom links with this snippet.
Then what do we use for post id , when we want to use an external link?
I want one of my featured pages to be http://www.ottawarunforpalestine.com/
May i use this snippet for chosing blog-entries as a featured page? Will the “F. P. Unlimited” give me the option to select blog-entries without this snippet?
Thanks
Mark
Hi Mark,
You can use this snippet with the FP unlimited extension to add a custom link.
The FP Unlimited extension will be updated soon with this feature (choose a blog post in a list) since it is a recurrent request from users.
Best and enjoy the theme
Is there a way to make a “product” page from WooCommerce plugin into one of these featured pages?
Hi Dan, this is not possible as of now but this will be improved with additional filters in the next release of the theme.
Thanks for this feedback!
Also, where exactly inside the functions.php file do you paste this code? Does it matter? I’m getting an error when I try this.
You might want to read this quick guide on how to customizr the WordPress Customizr theme : http://www.presscustomizr.com/customizr/how-to-customize-customizr-wordpress-theme/
Cheers
So you mean i can’t use this snippet without the fp-unlimited pack? So i will buy it because my complete page consits of blog entries. Only some legal disclaimers were “sites”.
You can use this snippet without the FP unlimited plugin!
Best
Hi there
First of all – thanks for a great them. I’m new to wordpress and this is the best one I’ve found!
My question is – Can you set the one of the featured pages to display categories instead of pages at all?
Keep up the good work 🙂
Thanks
Jeff
Hi Jeff, this option is not available yet but is planned to be included in the Featured Pages Unlimited extension.
Best
Hi Nicolas, this is most awesome. I had to use a little work around to achieve categories instead of featured pages links from the start page. I sure hope you implement this officially somewhen later. Best regards!
Hi Pavel thanks for this feedback.
Feel free to post your work around, this will surely be interesting for other users of the theme.
Best
Nothing fancy, just followed your instructions and instead of assigning a custom link by page id
I replaced them with the category ids
OK thanks for sharing Pavel.
Yes. Thank you much for this. I ended up doing a similar work-around adding the permalink to category. But the excerpt is pulled from the selected page, as opposed to the custom link, correct? Would that be different with the plug-in (when new version implemented)?