January 15, 2014 at 11:05 pm #210335
At the moment there are three page templates (default template, archive and blank). I want to add one. I understand that I can just copy an existing one (per example template-builder.php) and save in under a new name. But where do I tell the theme that there is now a new template available?
Also: I’m using enfold as a child theme. Just in case this changes the way I have to add this new page template.
Thank you for any help…January 16, 2014 at 12:09 am #210371
Your best source on getting started with creating page templates is the codex: http://codex.wordpress.org/Page_Templates
DevinJanuary 16, 2014 at 9:57 am #210584
thank you for the quick reply.
i kind of get how to create a new page template. i just need to name it the right way. but is there also a way to create a new template which i can choose from within a page while i edit it? here:
and another question:
i want to show a fullwidth map within this new page template i’m creating. but i can’t get it to work. i inserted a div tag right after the container is closed. inside this div tag i put a shortcode. now the frontend only shows the code but doesn’t replace it by the map. how can i make this work?
the full page template looks like that:
<?php global $avia_config; /* * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory. */ get_header(); if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title(); ?> <div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'> <div class='container'> <main class='template-page content <?php avia_layout_class( 'content' ); ?> units' <?php avia_markup_helper(array('context' => 'content','post_type'=>'page'));?>> <?php /* Run the loop to output the posts. * If you want to overload this in a child theme then include a file * called loop-page.php and that will be used instead. */ $avia_config['size'] = avia_layout_class( 'main' , false) == 'entry_without_sidebar' ? '' : 'entry_with_sidebar'; get_template_part( 'includes/loop', 'page' ); ?> <!--end content--> </main> <?php //get the sidebar $avia_config['currently_viewing'] = 'page'; get_sidebar(); ?> </div><!--end container--> </div><!-- close default .container_wrap element --> <div class='map-fullwidth'>[wpgmza id="2"]</div> <?php get_footer(); ?>January 16, 2014 at 10:58 am #210610
1) Yes, you just need to tell wordpress the template name. At the very beginning of your page template replace
<?php /* Template Name: Archives with Content */
and instead of “Archives with Content” your a custom template name.
2) WordPress won’t execute shortcodes in php code automatically. However it comes with a do_shortcode() function which enables you to embed shortcodes into php/html code. In this case replace
<div class='map-fullwidth'>[wpgmza id="2"]</div>
<div class='map-fullwidth'> <?php do_shortcode('[wpgmza id="2"]'); ?> </div>
and the map should pop up.
PeterJanuary 16, 2014 at 11:40 am #210627
thank you very much for your help!
just a little remark. the code should be:
<div class='map-fullwidth'> <?php echo do_shortcode('[wpgmza id="2"]'); ?> </div>
you forgot the “echo”. but now its working perfectly.
- This reply was modified 3 years, 2 months ago by romanalbertini.
The topic ‘How to create a new page template’ is closed to new replies.