Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!