Community Forums › Forums › Archived Forums › General Discussion › HELP! Creating full width-page template WITHOUT sidebar
Tagged: page template
- This topic has 4 replies, 2 voices, and was last updated 8 years, 10 months ago by germandude.
-
AuthorPosts
-
February 5, 2016 at 2:32 pm #178402germandudeMember
Hello everyone,
I use the Lifestyle Pro-Theme for my website handgepaeckguide.de.
I adjusted the function.php so that there is a full with header and a full
width footer. The area between the header and footer is divided into a
main content area and a sidebar.Now, I would like to create a page template where the area between the
header and the footer has no sidebar and consists only of a (full width-)main content
area.And I want to create a new CSS class to modify the width and other
attributes of this main content area, (specifically for this page
template).I understand, that I have to add a php-file to the Lifestyle Pro-Theme to
create the page template.But even after reading numerous blog posts, I was not able to figure out
what code this php-file exactly needs to contain to get the desired
result.I managed to create a page template without sidebar. But I failed to include the CSS-classes which allow me to adjust the width and other attributes of the main content area.
Can anyone help me out?
Thank you very much in advance!
Best regards from Germany,
http://handgepaeckguide.de/
AndréFebruary 5, 2016 at 8:11 pm #178410ChristophMemberHallo André,
you can include something like this code in your template:
//* Add custom body class to the head add_filter( 'body_class', 'sp_body_class' ); function sp_body_class( $classes ) { $classes[] = 'standard'; return $classes; }
Change 'standard' to whatever class you want to use.
You can use this class as "prefix" to only target pages using that page template.
e.g. .standard .entry-title
February 6, 2016 at 12:31 pm #178471germandudeMemberHello Christoph,
thank you very much for your answer.
The code snippet you provided me with does not exactly lead to the result that I wished for.
The newly created class affects the attributes of the whole website, including the header, menu and footer.
I aimed at creating a class that allows me to only change the attributes (particularly the width and padding) of the main content area between the main menu and the footer.
I get the result I wished for, when putting this code in the page template-file:
<?php
/*
* Template Name: Page without Sidebar
*/add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
}//loads the framework
genesis();And by controlling the width of the page with a simple <div>-tag in the page-editor.
It seems to work, but it would feel „cleaner“ if I created a class in the php template-file.
Best regards,
AndréFebruary 6, 2016 at 12:37 pm #178473ChristophMemberHallo André,
If you want to add a class to an element you can use the genesis_attr filter
https://wpbeaches.com/adding-attribute-html-section-genesis/
February 6, 2016 at 2:50 pm #178481germandudeMemberHello Christoph,
that worked perfectly, thank you very much!
For everybody who is havin the same problem, this is the code of my page template:
<?php
/*
* Template Name: Page without Sidebar
*/add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
add_filter( 'genesis_attr_entry-content', 'themeprefix_add_css_attr' );
function themeprefix_add_css_attr( $attributes ) {// add original plus extra CSS classes
$attributes['class'] .= ' ohnesidebar';// return the attributes
return $attributes;}
//loads the framework
genesis();Best regards,
André -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.