• Resolved ajeclizm

    (@ajeclizm)


    Is there a way to set which page template to use when creating a new doc? I’d like it to use a custom template instead of the default template. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I tried for hours to use elementor templates but never figured out how… hope they will answer 😛

    Plugin Author David Cavins

    (@dcavins)

    This is a great question, and it’s complicated because we are using what WordPress refers to as an “archive page”. When I view the page using Query Monitor on a vanilla WP installation, I see this:

    Template File
      page.php
    
    Template Hierarchy
      archive-bp_doc.php
      archive.php
      index.php

    which means that after looking through the theme for the most appropriate template file to use, WP is choosing page.php from my theme, TwentyNineteen.

    Changing that wrapper easily depends on if your theme gives you the ability to do it, but most don’t (it’s an unusual need unless you’re building something more complicated than a blog). You can specify which template to use for the edit/create page using a filter like this:

    add_filter( 'template_include', 'bp_docs_specify_page_template_for_edit_view', 99 );
    function bp_docs_specify_page_template_for_edit_view( $template ) {
    	if ( bp_docs_is_doc_create() || bp_docs_is_doc_edit() ) {
    		$new_template = locate_template( array( 'page-special-tmpl.php' ) );
    		if ( '' != $new_template ) {
    			$template = $new_template ;
    		}
    	}
    	return $template;
    }

    where you replace page-special-tmpl.php with the filename of the template file you wish to use.

    • This reply was modified 1 year, 10 months ago by David Cavins.
    • This reply was modified 1 year, 10 months ago by David Cavins.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create New Doc default page template’ is closed to new replies.