Override Custom Archive Template in WordPress Elementor

PHP

Method 1:

Step 1: Create a Custom Archive Template

  1. In your WordPress dashboard, navigate to “Templates” and then “Theme Builder.”
  2. Click the “Add New” button to create a new template.
  3. Choose the “Archive” option to create an archive template.

Step 2: Design Your Custom Archive Template

  1. In the Elementor editor, design your custom archive template using the drag-and-drop interface.
  2. Add and arrange widgets, sections, and elements to create the desired layout and design.

Step 3: Save the Custom Archive Template

  1. Once you’ve designed the custom archive template, click the “Save” button to save your changes.
  2. Give your template a meaningful name and click “Save” again.

Step 4: Assign the Custom Archive Template

  1. After saving the template, click the “Publish” button to make it live.
  2. A popup will appear with options to assign the template. Choose where you want the template to be applied. You can assign it to specific categories, tags, or other conditions.

Step 5: Verify the Custom Archive Template

  1. Visit the front-end of your website and navigate to one of the categories or archive pages that you assigned the custom template to.
  2. You should now see your custom archive template in action.

Step 6: Troubleshooting

If your custom archive template is not showing up as expected, make sure to check the following:

  • Ensure that you have Elementor and a compatible theme installed and activated.
  • Verify that you have assigned the custom template to the correct categories or conditions.
  • Clear any cache or refresh your website to ensure changes take effect.

Step 7: Further Customization (Optional)

You can continue to edit and customize your custom archive template in Elementor anytime by going back to the Theme Builder and selecting the template you created.

Remember that the interface might vary slightly based on your theme and Elementor version. If you encounter any difficulties, refer to Elementor’s official documentation or seek support from their community or help resources.

Method 2:

Following code snippet customizes custom archive template for product pages using WordPress filters. It checks if the current page is a ‘product’ archive, then replaces the default template with ‘archive-product.php’ if found. This enhances display control.


add_filter( 'template_include', 'custom_archive_template', 99 );

function custom_archive_template( $template ) { 
    if ( is_post_type_archive( 'product' ) ) { 
        $new_template = locate_template( array( 'archive-product.php' ) ); 
        if ( '' != $new_template ) { 
            return $new_template ; 
        } 
    } 
    return $template; 
}

Leave a Reply