Avada Forums Community Forum Overwrite archive-avada_portfolio.php Reply To: Overwrite archive-avada_portfolio.php

Michael C
Keymaster
Post count: 539

Hi TheWebsiteEngineer,

For this you can add some extra code to your functions.php:


function my_portfolio_archive_template( $archive_post_template ) {
	$archive_portfolio_template = get_stylesheet_directory() . '/archive-avada_portfolio.php';
	
	// Checks if the archive is portfolio.
	if ( is_post_type_archive( 'avada_portfolio' )
		|| is_tax( 'portfolio_category' )
		|| is_tax( 'portfolio_skills' )
		|| is_tax( 'portfolio_tags' ) ) {
		if ( file_exists( $archive_portfolio_template ) ) {
			fusion_portfolio_scripts();
			return $archive_portfolio_template;
		}
	}
	return $archive_post_template;
}

remove_filter( 'archive_template', 'fusion_portfolio_archive_template' );
add_filter( 'archive_template', 'my_portfolio_archive_template' );

Note, you will also have to add portfolio-archive-layout.php or change the reference in your copied file.