WordPress.org

Support

Support » Themes and Templates » Constructor » Create addition template not working

Create addition template not working

  • I have the Constructor Theme (Version 1.6.5) for WordPress which I love! I have been able to make most of the site easily…great work! My problem is that all the tutorials to make a custom template don’t work for me. I have copied the page.php page and added the ‘Template name:’ comment in the opening PHP tag. I then try to change to the new template but when I view it there is a problem in that I can only see plain text menu to the left of page…no CSS nothing!!

    Any advice?

    Kind regards Russ Clarke

Viewing 9 replies - 1 through 9 (of 9 total)
  • Create a page with this “Custom template” and post its URL here.

    Hi Jesin

    Thanks for reply.

    I am developing it locally but here is a screenshot…http://shockproof.bpweb.net/test/screen-shot.jpg. I simply copied the page.php, renamed it to bcgc_home.php…added ‘/*
    Template name: BCGC Home */’ at the top. The page code is below…

    Thanks for looking

    <?php
    /*
    Template name: BCGC Home
    /**
     * @package WordPress
     * @subpackage constructor
     */
    __('BCGC Home', 'constructor'); // required for correct translation
    ?>
    <div id="content" class="box shadow opacity <?php the_constructor_layout_class() ?>">
        <div id="container">
        <?php get_constructor_slideshow(true) ?>
        <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); global $post; ?>
                <article <?php post_class(); ?> id="post-<?php the_ID() ?>">
                    <header class="opacity box">
                        <h1><?php the_title(); ?></h1>
                    </header>
                    <div class="entry">
                        <?php the_content(__('Read the rest of this entry &raquo;', 'constructor')) ?>
    				    <?php wp_link_pages(array('before' => '<p class="pages"><strong>'.__('Pages', 'constructor').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
                    </div>
                    <footer>
                        <?php edit_post_link(__('Edit', 'constructor'), '', ' | '); ?>
                        <?php if ($post->post_parent) : $parent_link = get_permalink($post->post_parent); ?>
                        <a href="<?php echo $parent_link; ?>"><?php _e('Back to Parent Page', 'constructor');?></a> |
                        <?php endif; ?>
                        <?php if (get_constructor_option('content', 'date')) { the_date(); echo ' | '; } ?>
                        <?php if (get_constructor_option('content', 'links', 'comments')) {
                            comments_popup_link(
                                __('No Comments »', 'constructor'),
                                __('1 Comment »', 'constructor'),
                                __('% Comments »', 'constructor'),
                                'comments-link',
                                __('Comments Closed', 'constructor')
                            );
                        } ?>
                    </footer>
                </article>
            <?php endwhile; ?>
        <?php else: get_constructor_nothing(); endif; ?>
        </div><!-- id='container' -->
        <?php get_constructor_sidebar(); ?>
    </div><!-- id='content' -->

    OK I have worked some of it out. The Constructor theme is slightly different. The template pulls layouts from the ‘/layouts‘ folder. So I have copied ‘page.php‘ in the root and called it cover.php…it looks like this…

    <?php
    /**
    Template name: Cover
     * @package WordPress
     * @subpackage Constructor
     */
    wp_enqueue_script( 'comment-reply' );
    
    // load header.php
    get_header('cover');
    
    // load one of layout pages (layouts/*.php) based on settings
    get_constructor_layout('cover');
    
    // load footer.php
    get_footer();

    I have copied header.php and called it header-cover.php and it is working fine. I then copied layouts/page.php and renamed it page-cover.php but it does not pull the layout into the template!! I have also tried naming the layout file just cover.php…still no luck. Any ideas…very frustrating!

    You have copied the page.php file which is inside the layout/ directory. This won’t work as expected.

    First create a Child theme. Inside wp-content/themes/constructor-child create a file called bcgc-home.php and place the following code.

    <?php
    /**
    Template Name: BCGC Home
     */
    wp_enqueue_script( 'comment-reply' );
    
    // load header.php
    get_header();
    
    __('Single', 'constructor'); // required for correct translation
    ?>
    <div id="content" class="box shadow opacity <?php the_constructor_layout_class() ?>">
        <div id="container">
        <?php get_constructor_slideshow(true) ?>
        <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); global $post; ?>
                <article <?php post_class(); ?> id="post-<?php the_ID() ?>">
                    <header class="opacity box">
                        <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'constructor'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h1>
                    </header>
                    <div class="entry">
                        <?php the_content(__('Read the rest of this entry »', 'constructor')) ?>
    				    <?php wp_link_pages(array('before' => '<p class="pages"><strong>'.__('Pages', 'constructor').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
                    </div>
                    <footer>
                        <?php edit_post_link(__('Edit', 'constructor'), '', ' | '); ?>
                        <?php if ($post->post_parent) : $parent_link = get_permalink($post->post_parent); ?>
                        <a href="<?php echo $parent_link; ?>"><?php _e('Back to Parent Page', 'constructor');?></a> |
                        <?php endif; ?>
                        <?php if (get_constructor_option('content', 'date')) { the_date(); echo ' | '; } ?>
                        <?php if (get_constructor_option('content', 'links', 'comments')) {
                            comments_popup_link(
                                __('No Comments »', 'constructor'),
                                __('1 Comment »', 'constructor'),
                                __('% Comments »', 'constructor'),
                                'comments-link',
                                __('Comments Closed', 'constructor')
                            );
                        } ?>
                    </footer>
                </article>
            <?php endwhile; ?>
            <?php comments_template(); ?>
        <?php else: get_constructor_nothing(); endif; ?>
        </div><!-- id='container' -->
        <?php get_constructor_sidebar(); ?>
    </div><!-- id='content' -->
    <?php
    // load footer.php
    get_footer();

    Edit it as you want.

    Hi Jeslin

    This doesn’t seem to work. I have read about Child Themes and you have to activate them in Appearance>>Themes. When I go there it tells me my child theme is broken and needs a stylesheet! Do I import the main theme stylesheet?

    Russ

    esmi

    @esmi

    Forum Moderator

    Hi Jesin

    I have decided to go down a different root for now. I am going to use the existing ‘single template and recode it.

    Thanks for the help…appreciated!

    Russ

    Hi Russ,

    Whatever you do inside wp-content/themes/constructor will be overwritten when you update your theme. This includes newly created files in this directory.

    You need to have the following inside wp-content/themes/constructor-child/style.css

    /*
    Theme Name: Constructor Child
    Template: constructor
    */
    @import url('../constructor/style.css');

    Hi Jesin

    OK I think I have got it sorted now. Thank you for the help. I have setup the child theme and although I had to re do the sidebar widgets everything seems to be working OK.

    cheers

    Russ

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Create addition template not working’ is closed to new replies.
Skip to toolbar