Advertisement
pratikshrestha

Catch Reponsive Sidebar Only on Homepage

Feb 27th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.68 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The Sidebar containing the primary widget area
  4.  *
  5.  * @package Catch Themes
  6.  * @subpackage Catch Responsive
  7.  * @since Catch Responsive 1.0
  8.  */
  9. ?>
  10.  
  11. <?php
  12. /**
  13.  * catchresponsive_before_secondary hook
  14.  */
  15. do_action( 'catchresponsive_before_secondary' );
  16.  
  17. $catchresponsive_layout = catchresponsive_get_theme_layout();
  18.  
  19. if ( 'no-sidebar' == $catchresponsive_layout ) {
  20.     return;
  21. }
  22.  
  23. global $wp_query;
  24.  
  25. // Front page displays in Reading Settings.
  26. $page_on_front = get_option( 'page_on_front' );
  27. $page_for_posts = get_option( 'page_for_posts' );
  28.  
  29. // Get Page ID outside Loop.
  30. $page_id = $wp_query->get_queried_object_id();
  31.  
  32. /**
  33.  * catchresponsive_before_primary_sidebar hook
  34.  */
  35. do_action( 'catchresponsive_before_primary_sidebar' );
  36. ?>
  37.  
  38. <aside class="sidebar sidebar-primary widget-area" role="complementary">
  39. <?php
  40. //Primary Sidebar
  41. if ( is_active_sidebar( 'primary-sidebar' ) && ( is_front_page() || ( is_home() && $page_id != $page_for_posts ) ) ) {
  42.     dynamic_sidebar( 'primary-sidebar' );
  43.     }
  44. else {
  45.     //Helper Text
  46.     if ( current_user_can( 'edit_theme_options' ) ) { ?>
  47.         <section id="widget-default-text" class="widget widget_text">
  48.             <div class="widget-wrap">
  49.                 <h4 class="widget-title"><?php _e( 'Primary Sidebar Widget Area', 'catch-responsive' ); ?></h4>
  50.  
  51.                 <div class="textwidget">
  52.                     <p><?php _e( 'This is the Primary Sidebar Widget Area if you are using a two or three column site layout option.', 'catch-responsive' ); ?></p>
  53.                     <p><?php printf( __( 'By default it will load Search and Archives widgets as shown below. You can add widget to this area by visiting your <a href="%s">Widgets Panel</a> which will replace default widgets.', 'catch-responsive' ), admin_url( 'widgets.php' ) ); ?></p>
  54.                 </div>
  55.             </div><!-- .widget-wrap -->
  56.         </section><!-- #widget-default-text -->
  57.     <?php
  58.     } ?>
  59.     <section class="widget widget_search" id="default-search">
  60.         <div class="widget-wrap">
  61.             <?php get_search_form(); ?>
  62.         </div><!-- .widget-wrap -->
  63.     </section><!-- #default-search -->
  64.     <section class="widget widget_archive" id="default-archives">
  65.         <div class="widget-wrap">
  66.             <h4 class="widget-title"><?php _e( 'Archives', 'catch-responsive' ); ?></h4>
  67.             <ul>
  68.                 <?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
  69.             </ul>
  70.         </div><!-- .widget-wrap -->
  71.     </section><!-- #default-archives -->
  72.     <?php
  73. } ?>
  74. </aside><!-- .sidebar sidebar-primary widget-area -->
  75.  
  76. <?php
  77. /**
  78.  * catchresponsive_after_primary_sidebar hook
  79.  *
  80.  */
  81. do_action( 'catchresponsive_after_primary_sidebar' );
  82.  
  83. /**
  84.  * catchresponsive_after_secondary hook
  85.  *
  86.  */
  87. do_action( 'catchresponsive_after_secondary' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement