Twenty Thirteen Theme 二〇一三主题

Twenty Thirteen Theme 二〇一三主题

Codex Home → BuddyPress Theme Development → BP Theme Compatibility and the WordPress Default Themes → Twenty Thirteen Theme
Twenty Thirteen Theme

A. One column Layout
One Column Layout. Click on image to enlarge.
This is the default layout of the Twenty Thirteen theme if and only if you do not add any widget in the Secondary Widget area in Appearance > Widgets. Otherwise, the Twenty Thirteen theme will automatically have a two-column layout if you add widget to the Secondary Widget area.
If you want to add widgets in the Secondary Widget area for your site』s pages/posts but would prefer a one-column layout for all BP pages, following are the steps to do so.
1. Create a child theme of the Twenty Thirteen theme.
2. Create a new file in your new child theme folder and name it buddypress.php.
3. Copy over the content of Twenty Thirteen』s page.php file into the new buddypress.php file. Remove the get_sidebar tag just before the get_footer call in the template.
?12345678910111213141516171819     

        

                                                

    

 
4. Create a blank functions.php file in the folder of your child theme if you don』t have one yet. You will need to remove the .sidebar body class generated if any widget is added to the Secondary Widget Area which would move the alignment of the content area away from the center,
5. Add the following to the new functions.php file then save file.
?1234567891011 $value) {             if ($value == 'sidebar') unset($wp_classes[$key]);        }    endif;    return $wp_classes;}add_filter('body_class', 'mme_remove_sidebar_body_class', 20, 2);
6. Upload your Twenty Thirteen child theme folder to server.
B. Full Width Layout
Full-width Layout. Click on image to enlarge.
You can create a full-width layout for all BP pages even when the Secondary Widget Area (right sidebar) is active for rest of the site by following these steps.
1. Create a child theme of the Twenty Thirteen theme.
2. Create a new file in your new child theme folder and name it buddypress.php.
3. Copy over the content of Twenty Thirteen』s page.php file into the new buddypress.php file. Remove the get_sidebar tag just before the get_footer call in the template as well as the section with the call to post_thumbnail and save file.
?12345678910111213141516171819     

        

                                                

    

 
4. Create a blank functions.php file in the folder of your child theme if you don』t have one yet. You will need to remove the sidebar body class generated if any widget is added to the Secondary Widget Area which would show up in regular blog posts/pages,
5. Add the following to your new functions.php file then save file.
?1234567891011 $value) {             if ($value == 'sidebar') unset($wp_classes[$key]);        }    endif;    return $wp_classes;}add_filter('body_class', 'mme_remove_sidebar_body_class', 20, 2);
6. Open up your child theme』s style.css file, add the following and save file.
?1234567891011121314151617.buddypress .entry-header,.buddypress .entry-content,.buddypress .entry-summary,.buddypress .entry-meta {    max-width: 1040px;    width: 100%;} @ media (max-width: 1069px) {    .buddypress .entry-header,    .buddypress .entry-content,    .buddypress .entry-summary,    .buddypress .entry-meta {        padding-left: 20px;        padding-right: 20px;    }}
– delete the space between @ and media in media query above.
7. Upload your Twenty Thirteen child theme folder to server.
C. Two Column, Right Sidebar Layout
Two-column Layout. Click on image to enlarge.
When you add any widget to the Secondary Widget Area in Appearance > Widgets using the Twenty Thirteen theme, the right sidebar will automatically show up in all posts and pages including the BuddyPress pages. So if you plan to have the same widgets in the right sidebar throughout the site, then you can stop reading at this point as you will not have to do anything further.
However, if you want to customize the sidebar content of all your BP pages, you can do so by: a) using a plugin like Widget Logic to assign widgets to specific pages by using conditional tags or b) by creating new buddypress.php and sidebar-buddypress.php files and then registering a new widget area in your child theme』s functions.php file. The following steps are for the second option.
1. Create a child theme of the Twenty Thirteen theme.
2. Create a new file in your new child theme folder and name it buddypress.php.
3. Copy over the content of Twenty Thirteen』s page.php file into a new buddypress.php file and remove the section about retrieving the post_thumbnail. Then you will have to change get_sidebar() to get_sidebar(『buddypress』).
?12345678910111213141516171819202122232425262728293031323334353637     

        

                              <article id="post-" >                    

                        

                    

                     

                                                 '

', 'link_before' => '', 'link_after' => '' ) ); ?>                    

                     

                        <?php edit_post_link( __( 'Edit', 'twentythirteen' ), '', '' ); ?>                    

                

                      

    

 
4. Create a blank functions.php file in the folder of your child theme if you don』t have one yet. You will be creating a new widget area for BuddyPress pages as well as adding a body class to help you style your two column layout.
5. Add the following to the new functions.php file then save file.
?1234567891011121314151617181920212223 __( 'BuddyPress Sidebar Widget Area', 'mmechildtheme' ),        'id'         => 'bp-sidebar',        'description'    => __( 'Appears in the sidebar section of all BuddyPress pages.', 'mmechildtheme' ),        'before_widget' => '

',        'before_title'  => '

',        'after_title'   => '

',    ) );}add_action( 'widgets_init', 'mme_register_bp_widgets_area' ); // Add the sidebar body class for BP pages if the Secondary Widget area is not activefunction mme_add_sidebar_body_class( $classes ) {    if ( function_exists ( 'bp_loaded' ) &&  !bp_is_blog_page() && !is_active_sidebar( 'sidebar-2' )  )  {        $classes[] = 'sidebar';    }    return $classes;}add_filter( 'body_class', 'mme_add_sidebar_body_class' );
6. Create a new file named sidebar-buddypress.php in your child theme folder and add the following:
?123456789101112131415161718192021     

 
8 . Upload your Twenty Thirteen child theme folder to server. You』ll need to add at least one widget to the BP Sidebar widget area.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注