Avada Forums Community Forum Overwrite archive-avada_portfolio.php

Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • TheWebsiteEngineer
    Participant
    Post count: 3

    Can anyone give me some pointers as to how to edit the Portfolio Archive template?

    If I add this file in a child theme as archive-avada_portfolio.php, it doesn’t work – but the single post (single-avada_portfolio.php) works

    Cheers

    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.

    TheDigitalMoose
    Participant
    Post count: 12

    @michael-c

    This is a great help, but a bit overkill for me – is there anyway I can change the page title that appears in the page title bar on the portfolio archive?

    I want to use the layouts available to the archive page, rather than creating a new page and using a portfolio shortcode.

    Thanks

    Michael C
    Keymaster
    Post count: 539

    Hi @TheDigitalMoose,

    As in the page which is usually /portfolio-items/ ? Change the text from “Portfolio” to something else? If so I would recommend translating it. You can use translation files for the fusion-core to translate “Portfolio” to some other term. That then will also be used in the page title and on the back-end for the portfolio post type.

    Alternatively you could filter the title directly like so:

    function my_portfolio_title( $label, $post_type ) {
    	if ( 'avada_portfolio' === $post_type ) {
    		return 'My Portfolio Title';
    	}
    	return $label;
    }
    add_filter( 'post_type_archive_title', 'my_portfolio_title', 2, 10 );

    Or also other options (like copying title bar template or function to child and editing)

    einkauf2016
    Participant
    Post count: 5

    Sorry but it doesnt work for me.

    I have copied the code to the functions.php
    and copied the both files:
    archive-avada_portfolio.php
    portfolio-archive-layout.php

    into the /Avada-Child-Theme folder

    And as it doesnt work I tried next to copy
    into /Avada-Child-Theme/templates folder

    nothing happens.

    Any suggestions?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.