Community Forums › Forums › Archived Forums › Design Tips and Tricks › Creating Custom Pages
- This topic has 23 replies, 3 voices, and was last updated 12 years, 1 month ago by sahdow.
-
AuthorPosts
-
November 28, 2012 at 5:52 pm #2177sdmMember
I would like to create another page on my site that looks like the homepage. I am told that I have to create a custom template, but I am not sure how to make that happen. Any suggestions?
I am using the Executive Theme.
November 29, 2012 at 2:28 pm #2381SoZoMemberYou can read about creating page templates here.
John “Nicolas Flamel” Wright | SoZo’s design| John Wright Photography
November 29, 2012 at 4:52 pm #2404sdmMemberThanks so much! This worked! Now I have to create another set of widgets to control this page I created. Otherwise, it will just show the same content as the homepage, which is not what I want...
Help again?
sdm 🙂
November 29, 2012 at 4:55 pm #2405SoZoMemberNovember 29, 2012 at 5:19 pm #2411sdmMemberI see...
November 29, 2012 at 10:10 pm #2457sdmMemberSozo...I read it....but I am still confused. 🙁
I have created the new sidebars using the genesis plug in, but I am cannot see how to change the code to read them, or how to create another slider.
Should I find a developer, or can this be done?
sdm 🙂
November 30, 2012 at 7:45 am #2490sahdowParticipantYou can't do that with the plugin (making an internal page that looks like the homepage). Sidebar is a term used by WordPress for all widgeted areas even if they are in the footer.
Using the information on the page Sozu referenced, specifically "Register Your Sidebar" , the easiest way to do it is.
Copy content of home into custom page template, copy widgetet areas from functions and paste into fucntions.
Change the ID and Name in the "register your sidebar code" so it is unique;
Easiest way would be to simply change id from home to page (ie page-slider, page-top, page-cta, page-middle)
Note bolded areas - also, you will hoave to make any necessary CSS modifications once you get the widgets working
/** Register widget areas **/
genesis_register_sidebar( array(
'id' => 'home-slider',
'name' => __( 'Home - Slider', 'executive' ),
'description' => __( 'This is the slider section on the home page.', 'executive' ),
) );
genesis_register_sidebar( array(
'id' => 'home-top',
'name' => __( 'Home - Top', 'executive' ),
'description' => __( 'This is the top section of the home page.', 'executive' ),
) );
genesis_register_sidebar( array(
'id' => 'home-cta',
'name' => __( 'Home - Call To Action', 'executive' ),
'description' => __( 'This is the call to action section on the home page.', 'executive' ),
) );
genesis_register_sidebar( array(
'id' => 'home-middle',
'name' => __( 'Home - Middle', 'executive' ),
'description' => __( 'This is the middle section of the home page.', 'executive' ),
) );change the id in the code of the custom page template to match the same changes.
<!--?php /**
* This file adds the custom template to the Executive Child Theme.
*
* @author StudioPress
* @package Generate
* @subpackage Customizations
*//*
Template Name: Custom
*/function executive_home_genesis_meta() {
if ( is_active_sidebar( 'home-slider' ) || is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-cta' ) || is_active_sidebar( 'home-middle' ) ) {
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'executive_home_sections' );
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
add_filter( 'body_class', 'executive_body_class' );
add_action( 'genesis_after', 'executive_slider_excerpt_position' );/** Add body class to home page **/
function executive_body_class( $classes ) {
$classes[] = 'executive-home';
return $classes;
}/** Moves the slider pager if the sidebars are active and the screen is wide enough */
function executive_slider_excerpt_position() {
?>
<script type="text/javascript">
jQuery(document).ready(function() {
if (jQuery(".slide-excerpt").length > 0) {
jQuery(".flex-control-nav").addClass("nav-pos-excerpt");
}
});
</script>
<!--?php }
}
}function executive_home_sections() {
if ( is_active_sidebar( 'home-slider' ) || is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-cta' ) || is_active_sidebar( 'home-middle' ) ) {
genesis_widget_area( 'home-slider', array(
'before' => '<div class="home-slider widget-area">',
) );genesis_widget_area( 'home-top', array(
'before' => '<div class="home-top widget-area">',
) );genesis_widget_area( 'home-cta', array(
'before' => '<div class="home-cta widget-area">',
) );genesis_widget_area( 'home-middle', array(
'before' => '<div class="home-middle widget-area">',
) );}
}
genesis();
November 30, 2012 at 9:46 am #2521sdmMemberHi Sahdow...I already created the page...I cannot find this register your sidebar area. Please tell me where it is.
November 30, 2012 at 9:47 am #2522sdmMemberHere's the code for the page I created:
<?php /* Template Name: NewBlog */ ?>
<?php
add_action( 'genesis_meta', 'executive_home_genesis_meta' ); /** * Add widget support for homepage. If no widgets active, display the default loop. * */ function executive_home_genesis_meta() {
if ( is_active_sidebar( 'home-slider2' ) || is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-cta' ) || is_active_sidebar( 'home-middle' ) ) {
remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'executive_home_sections' ); add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); add_filter( 'body_class', 'executive_body_class' ); add_action( 'genesis_after', 'executive_slider_excerpt_position' );
/** Add body class to home page **/ function executive_body_class( $classes ) { $classes[] = 'executive-home'; return $classes; }
/** Moves the slider pager if the sidebars are active and the screen is wide enough */ function executive_slider_excerpt_position() { ?> <script type="text/javascript"> jQuery(document).ready(function() { if (jQuery(".slide-excerpt").length > 0) { jQuery(".flex-control-nav").addClass("nav-pos-excerpt"); } }); </script> <?php } } }
function executive_home_sections() {
if ( is_active_sidebar( 'home-slider' ) || is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-cta' ) || is_active_sidebar( 'home-middle' ) ) {
genesis_widget_area( 'home-slider', array( 'before' => '<div>', ) );
genesis_widget_area( 'home-top', array( 'before' => '<div>', ) );
genesis_widget_area( 'home-cta', array( 'before' => '<div>', ) );
genesis_widget_area( 'home-middle', array( 'before' => '<div>', ) ); }
}
genesis();
November 30, 2012 at 9:51 am #2526sahdowParticipantfunctions.php and you page can not use the same ids as the home page or it will load the widgets from the home page unless you use conditional logic.
Re-read the top of my last post
November 30, 2012 at 11:38 am #2561sdmMemberI know that...I just don't see where to put what you're telling me to change. 🙁
November 30, 2012 at 12:08 pm #2567SoZoMemberYou can use Simple Sidebars to register the sidebars if you want to. Then you just need to change the sidebar IDs in your new page template to match the sidebars you registered in Simple Sidebars. If you want to register the new sidebars through functions.php then you can just copy/paste the existing sidebar registrations at the bottom of functions.php then change the names and the IDs.
John “Nicolas Flamel” Wright | SoZo’s design| John Wright Photography
November 30, 2012 at 12:35 pm #2583sahdowParticipantSozo is right, I forgot it's a page template, so there is a place to select the simple sidebars.
As for my example, all the bolded items are what need to be changed.
November 30, 2012 at 3:43 pm #2629sdmMemberCan I just pay someone to do this...I am obviously not getting it. You guys have been great...but I am out of my area, I think. 🙂
November 30, 2012 at 3:58 pm #2639sdmMemberIs this is file I need to change for the sidebars?
<?php /** Start the engine */ require_once( get_template_directory() . '/lib/init.php' );
/** Add theme color body class */ add_filter('body_class', 'add_category_class_single'); function add_category_class_single($classes){ $classes[] = 'executive-' . $_GET['color']; return $classes; }
load_child_theme_textdomain( 'executive', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'executive' ) );
/** Child theme (do not remove) */ define( 'CHILD_THEME_NAME', __( 'Executive Theme', 'executive' ) ); define( 'CHILD_THEME_URL', 'http://www.studiopress.com/themes/executive' );
/** Add Viewport meta tag for mobile browsers */ add_action( 'genesis_meta', 'executive_add_viewport_meta_tag' ); function executive_add_viewport_meta_tag() { echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>'; }
/** Add support for custom header */ add_theme_support( 'genesis-custom-header', array( 'width' => 1140, 'height' => 100 ) );
/** Add support for custom background */ add_theme_support( 'custom-background' );
/** Sets Content Width */ $content_width = apply_filters( 'content_width', 680, 680, 1020 );
/** Create additional color style options */ add_theme_support( 'genesis-style-selector', array( 'executive-brown' => __( 'Brown', 'executive' ), 'executive-green' => __( 'Green', 'executive' ), 'executive-orange' => __( 'Orange', 'executive' ), 'executive-purple' => __( 'Purple', 'executive' ), 'executive-red' => __( 'Red', 'executive' ), 'executive-teal' => __( 'Teal', 'executive' ), ) );
/** Unregister layout settings */ genesis_unregister_layout( 'content-sidebar-sidebar' ); genesis_unregister_layout( 'sidebar-content-sidebar' ); genesis_unregister_layout( 'sidebar-sidebar-content' );
/** Unregister secondary sidebar */ unregister_sidebar( 'sidebar-alt' );
/** Add new image sizes */ add_image_size( 'featured', 285, 100, TRUE ); add_image_size( 'portfolio', 300, 200, TRUE ); add_image_size( 'slider', 1140, 445, TRUE );
/** Remove the site description */ remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
/** Relocate the post info */ remove_action( 'genesis_before_post_content', 'genesis_post_info' ); add_action( 'genesis_before_post_title', 'genesis_post_info' );
/** Customize the post info function */ add_filter( 'genesis_post_info', 'post_info_filter' ); function post_info_filter($post_info) { if (!is_page()) { $post_info = ' <div class=\'date-info\'>' . __('posted on', 'executive' ) . ' [post_date format="F j, Y" before="<span class=\'date\'>" after="</span>"] ' . __('by', 'executive' ) . ' [post_author_posts_link] [post_edit] </div> <div> [post_comments] </div>'; return $post_info; } }
/** Change the default comment callback */ add_filter( 'genesis_comment_list_args', 'executive_comment_list_args' ); function executive_comment_list_args( $args ) { $args['callback'] = 'executive_comment_callback'; return $args; }
/** Customize the comment section */ function executive_comment_callback( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<?php do_action( 'genesis_before_comment' ); ?> <div> <div> <?php echo get_avatar( $comment, $size = $args['avatar_size'] ); ?> <?php printf( '<cite>%s</cite> <span>%s:</span>', get_comment_author_link(), apply_filters( 'comment_author_says_text', __( 'says', 'executive' ) ) ); ?> <div> <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( '%1$s ' . __('at', 'executive' ) . ' %2$s', get_comment_date(), get_comment_time() ); ?></a> <?php edit_comment_link( __( 'Edit', 'executive' ), g_ent( '• ' ), '' ); ?> </div><!-- end .comment-meta --> </div><!-- end .comment-author --> </div><!-- end .comment-header -->
<div> <?php if ($comment->comment_approved == '0') : ?> <p><?php echo apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'executive' ) ); ?></p> <?php endif; ?>
<?php comment_text(); ?> </div><!-- end .comment-content -->
<div> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> </div>
<?php do_action( 'genesis_after_comment' );
/** No ending </li> tag because of comment threading */
}
/** Create portfolio custom post type */ add_action( 'init', 'executive_portfolio_post_type' ); function executive_portfolio_post_type() { register_post_type( 'portfolio', array( 'labels' => array( 'name' => __( 'Portfolio', 'executive' ), 'singular_name' => __( 'Portfolio', 'executive' ), ), 'exclude_from_search' => true, 'has_archive' => true, 'hierarchical' => true, 'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png', 'public' => true, 'rewrite' => array( 'slug' => 'portfolio' ), 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo' ), ) ); }
/** Change the number of portfolio items to be displayed (props Bill Erickson) */ add_action( 'pre_get_posts', 'executive_portfolio_items' ); function executive_portfolio_items( $query ) {
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) { $query->set( 'posts_per_page', '12' ); }
}
/** Add support for 3-column footer widgets */ add_theme_support( 'genesis-footer-widgets', 3 );
/** Register widget areas **/ genesis_register_sidebar( array( 'id' => 'home-slider', 'name' => __( 'Home - Slider', 'executive' ), 'description' => __( 'This is the slider section on the home page.', 'executive' ), ) ); genesis_register_sidebar( array( 'id' => 'home-top', 'name' => __( 'Home - Top', 'executive' ), 'description' => __( 'This is the top section of the home page.', 'executive' ), ) ); genesis_register_sidebar( array( 'id' => 'home-cta', 'name' => __( 'Home - Call To Action', 'executive' ), 'description' => __( 'This is the call to action section on the home page.', 'executive' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle', 'name' => __( 'Home - Middle', 'executive' ), 'description' => __( 'This is the middle section of the home page.', 'executive' ),
November 30, 2012 at 4:00 pm #2646sahdowParticipantI don't want to step on any toes and I don't want to get paid for something like that either, but if you post exactly what you have so far on the page template and functions.php I'll tweak it since (as far as I can tell - you basically have it).
November 30, 2012 at 4:11 pm #2650sdmMemberHere are the sidebars I created.
They match the ones in the original template, but I added a 2 to the end.
home-slider2
home-top2
home-cta2
home-middle2
November 30, 2012 at 4:11 pm #2651sdmMemberHere's my function.php file...it has not been changed to include the newly created sidebars.
<?php /** Start the engine */ require_once( get_template_directory() . '/lib/init.php' );
/** Add theme color body class */ add_filter('body_class', 'add_category_class_single'); function add_category_class_single($classes){ $classes[] = 'executive-' . $_GET['color']; return $classes; }
load_child_theme_textdomain( 'executive', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'executive' ) );
/** Child theme (do not remove) */ define( 'CHILD_THEME_NAME', __( 'Executive Theme', 'executive' ) ); define( 'CHILD_THEME_URL', 'http://www.studiopress.com/themes/executive' );
/** Add Viewport meta tag for mobile browsers */ add_action( 'genesis_meta', 'executive_add_viewport_meta_tag' ); function executive_add_viewport_meta_tag() { echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>'; }
/** Add support for custom header */ add_theme_support( 'genesis-custom-header', array( 'width' => 1140, 'height' => 100 ) );
/** Add support for custom background */ add_theme_support( 'custom-background' );
/** Sets Content Width */ $content_width = apply_filters( 'content_width', 680, 680, 1020 );
/** Create additional color style options */ add_theme_support( 'genesis-style-selector', array( 'executive-brown' => __( 'Brown', 'executive' ), 'executive-green' => __( 'Green', 'executive' ), 'executive-orange' => __( 'Orange', 'executive' ), 'executive-purple' => __( 'Purple', 'executive' ), 'executive-red' => __( 'Red', 'executive' ), 'executive-teal' => __( 'Teal', 'executive' ), ) );
/** Unregister layout settings */ genesis_unregister_layout( 'content-sidebar-sidebar' ); genesis_unregister_layout( 'sidebar-content-sidebar' ); genesis_unregister_layout( 'sidebar-sidebar-content' );
/** Unregister secondary sidebar */ unregister_sidebar( 'sidebar-alt' );
/** Add new image sizes */ add_image_size( 'featured', 285, 100, TRUE ); add_image_size( 'portfolio', 300, 200, TRUE ); add_image_size( 'slider', 1140, 445, TRUE );
/** Remove the site description */ remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
/** Relocate the post info */ remove_action( 'genesis_before_post_content', 'genesis_post_info' ); add_action( 'genesis_before_post_title', 'genesis_post_info' );
/** Customize the post info function */ add_filter( 'genesis_post_info', 'post_info_filter' ); function post_info_filter($post_info) { if (!is_page()) { $post_info = ' <div class=\'date-info\'>' . __('posted on', 'executive' ) . ' [post_date format="F j, Y" before="<span class=\'date\'>" after="</span>"] ' . __('by', 'executive' ) . ' [post_author_posts_link] [post_edit] </div> <div> [post_comments] </div>'; return $post_info; } }
/** Change the default comment callback */ add_filter( 'genesis_comment_list_args', 'executive_comment_list_args' ); function executive_comment_list_args( $args ) { $args['callback'] = 'executive_comment_callback'; return $args; }
/** Customize the comment section */ function executive_comment_callback( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<?php do_action( 'genesis_before_comment' ); ?> <div> <div> <?php echo get_avatar( $comment, $size = $args['avatar_size'] ); ?> <?php printf( '<cite>%s</cite> <span>%s:</span>', get_comment_author_link(), apply_filters( 'comment_author_says_text', __( 'says', 'executive' ) ) ); ?> <div> <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( '%1$s ' . __('at', 'executive' ) . ' %2$s', get_comment_date(), get_comment_time() ); ?></a> <?php edit_comment_link( __( 'Edit', 'executive' ), g_ent( '• ' ), '' ); ?> </div><!-- end .comment-meta --> </div><!-- end .comment-author --> </div><!-- end .comment-header -->
<div> <?php if ($comment->comment_approved == '0') : ?> <p><?php echo apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'executive' ) ); ?></p> <?php endif; ?>
<?php comment_text(); ?> </div><!-- end .comment-content -->
<div> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> </div>
<?php do_action( 'genesis_after_comment' );
/** No ending </li> tag because of comment threading */
}
/** Create portfolio custom post type */ add_action( 'init', 'executive_portfolio_post_type' ); function executive_portfolio_post_type() { register_post_type( 'portfolio', array( 'labels' => array( 'name' => __( 'Portfolio', 'executive' ), 'singular_name' => __( 'Portfolio', 'executive' ), ), 'exclude_from_search' => true, 'has_archive' => true, 'hierarchical' => true, 'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png', 'public' => true, 'rewrite' => array( 'slug' => 'portfolio' ), 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo' ), ) ); }
/** Change the number of portfolio items to be displayed (props Bill Erickson) */ add_action( 'pre_get_posts', 'executive_portfolio_items' ); function executive_portfolio_items( $query ) {
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) { $query->set( 'posts_per_page', '12' ); }
}
/** Add support for 3-column footer widgets */ add_theme_support( 'genesis-footer-widgets', 3 );
/** Register widget areas **/ genesis_register_sidebar( array( 'id' => 'home-slider', 'name' => __( 'Home - Slider', 'executive' ), 'description' => __( 'This is the slider section on the home page.', 'executive' ), ) ); genesis_register_sidebar( array( 'id' => 'home-top', 'name' => __( 'Home - Top', 'executive' ), 'description' => __( 'This is the top section of the home page.', 'executive' ), ) ); genesis_register_sidebar( array( 'id' => 'home-cta', 'name' => __( 'Home - Call To Action', 'executive' ), 'description' => __( 'This is the call to action section on the home page.', 'executive' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle', 'name' => __( 'Home - Middle', 'executive' ), 'description' => __( 'This is the middle section of the home page.', 'executive' ), ) );
November 30, 2012 at 4:12 pm #2652SoZoMemberNo, you wouldn't use the selection part of Simple Sidebars. That is only for the Primary and Secondary Genesis sidebars. But you can register the sidebars in Simple Sidebars. The "selection" would take place by renaming the IDs in your new page template. But that's probably just clouding the issue. 🙁
Put this in your page template:
<?php
/*
Template Name: NewBlog
*/remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'executive_page_sections' );
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
add_filter( 'body_class', 'executive_body_class' );
add_action( 'genesis_after', 'executive_slider_excerpt_position' );/** Add body class to home page **/
function executive_body_class( $classes ) {
$classes[] = 'executive-home';
return $classes;
}/** Moves the slider pager if the sidebars are active and the screen is wide enough */
function executive_slider_excerpt_position() {
?>
<script type="text/javascript">
jQuery(document).ready(function() {
if (jQuery(".slide-excerpt").length > 0) {
jQuery(".flex-control-nav").addClass("nav-pos-excerpt");
}
});
</script>
<?php
}
}
}
function executive_page_sections() {genesis_widget_area( 'page-slider', array(
'before' => '<div class="home-slider widget-area">',
) );genesis_widget_area( 'page-top', array(
'before' => '<div class="home-top widget-area">',
) );genesis_widget_area( 'page-cta', array(
'before' => '<div class="home-cta widget-area">',
) );genesis_widget_area( 'page-middle', array(
'before' => '<div class="home-middle widget-area">',
) );}
genesis();
Then add this to the bottom of functions.php
genesis_register_sidebar( array(
‘id’ => 'page-slider‘,
‘name’ => __( ‘Page – Slider’, ‘executive’ ),
‘description’ => __( ‘This is the slider section on the page.’, ‘executive’ ),
) );
genesis_register_sidebar( array(
‘id’ => ‘page-top‘,
‘name’ => __( ‘Page – Top’, ‘executive’ ),
‘description’ => __( ‘This is the top section of the page.’, ‘executive’ ),
) );
genesis_register_sidebar( array(
‘id’ => ‘page-cta‘,
‘name’ => __( ‘Page – Call To Action’, ‘executive’ ),
‘description’ => __( ‘This is the call to action section on the page.’, ‘executive’ ),
) );
genesis_register_sidebar( array(
‘id’ => ‘page-middle‘,
‘name’ => __( ‘Page – Middle’, ‘executive’ ),
‘description’ => __( ‘This is the middle section of the page.’, ‘executive’ ),
) );
John “Nicolas Flamel” Wright | SoZo’s design| John Wright Photography
November 30, 2012 at 7:13 pm #2705sdmMemberSo...that would mean that there would be two sidebar sections in The functions.php code, am I understanding that, right? You guys are awesome to help me like this.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.