Advertisement
pratikshrestha

Lucida Pro Homepage Different Layout

Mar 19th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. /**
  2.  * Override parent function to set homepage layout to three-column
  3.  */
  4. function lucida_get_theme_layout() {
  5.     if ( is_home() || is_front_page() ) {
  6.         return 'three-columns';
  7.     }
  8.    
  9.     $id = '';
  10.  
  11.     // Set $id as Shop Page id for WooCommerce Pages excluding cart and checkout
  12.     if ( class_exists( 'woocommerce' ) && is_woocommerce() ) {
  13.         $id = get_option( 'woocommerce_shop_page_id' );
  14.     }
  15.     else {
  16.         global $post, $wp_query;
  17.  
  18.         // Front page displays in Reading Settings
  19.         $page_on_front  = get_option('page_on_front') ;
  20.         $page_for_posts = get_option('page_for_posts');
  21.  
  22.         // Get Page ID outside Loop
  23.         $page_id = $wp_query->get_queried_object_id();
  24.  
  25.         // Blog Page or Front Page setting in Reading Settings
  26.         if ( $page_id == $page_for_posts || $page_id == $page_on_front ) {
  27.             $id = $page_id;
  28.         }
  29.         else if ( is_singular() ) {
  30.             if ( is_attachment() ) {
  31.                 $id = $post->post_parent;
  32.             }
  33.             else {
  34.                 $id = $post->ID;
  35.             }
  36.         }
  37.     }
  38.  
  39.     //Get appropriate metabox value of layout
  40.     if ( '' != $id ) {
  41.         $layout = get_post_meta( $id, 'lucida-layout-option', true );
  42.     }
  43.     else {
  44.         $layout = 'default';
  45.     }
  46.  
  47.     //Load options data
  48.     $options = lucida_get_theme_options();
  49.  
  50.     //check empty and load default
  51.     if ( empty( $layout ) || 'default' == $layout ) {
  52.         if ( class_exists( 'woocommerce' ) && ( is_woocommerce() || is_cart() || is_checkout() ) ) {
  53.             $layout = $options['woocommerce_layout'];
  54.         }
  55.         else {
  56.             $layout = $options['theme_layout'];
  57.         }
  58.     }
  59.  
  60.     return $layout;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement