Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Stefan Vitasovic
Stefan Vitasovic
13,443 Points

Wordpress: Еxclude front-page.php from Advanced Excerpts

Hi guys! I'm developing a WP theme and am looking to exclude the front-page.php from the Advanced Excerpts plugin. There are options on the settings page of the plugin to exclude home.php, archive etc. but couldn't find a way to exclude the front-page. I went into the code and there is an option to set an array of pages to exclude - by default there is 'singular' listed. I'm looking to add 'front-page' to that array but the plugin fails to catch my change. If I list another page i.e. home php. it works with no problem.

Sorry for the long one, thanks in advance.

1 Answer

Gareth Borcherds
Gareth Borcherds
9,372 Points

So I just took a quick glance at the main class that you are probably referencing here: https://github.com/deliciousbrains/wp-advanced-excerpt/blob/master/class/advanced-excerpt.php

It looks like the developer as added a filter that you can tap into to pass the page types to it.

apply_filters( 'advanced_excerpt_skip_page_types', $skip_page_types )

So you just need to implement a function to pass an array to this filter. It would be something like:

add_filter('advanced_excerpt_skip_page_types', 'my_function_name');
function my_function_name() {
return array('front-page');
}

That is the correct way to add custom templates to this plugin based on what I saw in this guys code. I'd also like to point out that this would probably go in your theme's function.php file or a custom plugin. Make sure you name the function something super unique as to not mess with other plugins.

Hope this helps.

Stefan Vitasovic
Stefan Vitasovic
13,443 Points

I managed to hardcode smth for the time being. But this seems to be a more elegant and overall a proper way. Cheers!