• Resolved MitaLun

    (@mitalun)


    Hi,
    I’m not a coder but am trying to understand how I could make a new page template for my theme and style it. I have copied the page.php renamed it to page-nov-menu.php and uploaded it so now I have to page templates that are exactly the same. The new page template I want to style so it automatically adds a different margin to all pages using that template.

    Today I add the margin for each page in the style.css

    .page-id-250 .art-post {
    padding: 30px 30px 34px 230px;
    }

    This is the page code

    <?php
    /*
    Template Name: No vemnu
    */
    ?>
    
    <?php get_header(); ?>
    
    			<?php get_sidebar('top'); ?>
    
    			<?php
    
    			if (have_posts()) {
    
    				/* Start the Loop */
    
    				while (have_posts()) {
    
    					the_post();
    
    					get_template_part('content', 'page');
    
    				}
    
    			} else {
    
    				theme_404_content();
    
    			}
    
    			?>
    
    			<?php get_sidebar('bottom'); ?>
    
    <?php get_footer(); ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Could I add the margin directly in the code? If not how do you add it to the style.css so it picks up the new margin. Have tried different ways and googled and seen so many fils and read so many tutorials but nowhere can I find a solution that I understand.

    Any help would be very much appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • We need to see the site live to help with CSS issues.

    Thread Starter MitaLun

    (@mitalun)

    Hi, the site is not live unfortunately.So a general explanation how you style a new page template would be ok. I will use the same code as in my page.php so the only thing that I want to change is the left page margin on all pages using the new page template. The reason is that I have an image to the left and the vmenu goes on top of that but some pages will be without vmenu.

    Look in the generated HTML body tag – there may be a template-specific class or id that you can use to target pages using that template.

    your theme might be using body_class() in the body tag whihc will output a page template specific css class;

    http://codex.wordpress.org/Function_Reference/body_class#Page

    possibly:

    .page-template-page-nov-menu-php

    Thread Starter MitaLun

    (@mitalun)

    If I use firebug

    //
    <body class=”page page-id-121 page-template page-template-page2-php logged-in admin-bar customize-support”> //

    I know how to change for a specific page by using the page id but could I do something so every page using that template gets the margin?

    the css class seems to be:

    .page-template-page2-php

    is that the file name of your page template:
    page2.php ?

    Thread Starter MitaLun

    (@mitalun)

    Thank you It works like a charm now. Used a dot instead of dash before php………..

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How do I style my new page template’ is closed to new replies.