Advertisement
vailobox

Category Titles for Single Features

Jul 17th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.78 KB | None | 0 0
  1. <?php if(get_option("ocmx_hide_title") !="no") {
  2.     $parentpage = get_template_link(get_post_type().".php");
  3.     $pagetitle_copy = get_option("ocmx_pagetitle_copy");
  4.  
  5.     if (class_exists( 'Woocommerce' )) { if(function_exists('is_shop') && ( is_shop() || is_product() ) ) : ?>
  6.         <div id="title-container">
  7.             <div class="title-block">
  8.                 <?php
  9.                 $shop_page_id = woocommerce_get_page_id('shop');
  10.                 $shop_title = get_post( $shop_page_id );
  11.                 if( !is_object( $shop_title ) ) { ?>
  12.                     <h2><?php _e( 'Shop' , 'ocmx' ); ?></h2>
  13.                 <?php } else { ?>
  14.                     <h2><?php echo $shop_title->post_title; ?></h2>
  15.                 <?php }?>
  16.             </div>
  17.         </div>
  18.     <?php endif; } ?>
  19.     <?php if(!is_page() && get_query_var('term' ) != '' ) :
  20.         $term = get_term_by( 'slug', get_query_var('term' ), get_query_var( 'taxonomy' ) ); ?>
  21.         <div id="title-container">
  22.             <div class="title-block">
  23.                 <h2><?php echo $term->name; ?></h2>
  24.                 <?php if($pagetitle_copy !="no") :
  25.                     if ( !empty( $term->description) ) :
  26.                         echo '<p>'.$term->description.'</p>';
  27.                     else :
  28.                         false;
  29.                     endif;
  30.                 endif; ?>
  31.             </div>
  32.         </div>
  33.     <?php elseif(is_singular('features') || is_singular('services')) : ?>
  34.         <div id="title-container">
  35.         <div class="title-block">
  36.             <?php $terms = get_the_terms($post->id, 'features-category');                      
  37.                 if ( $terms && ! is_wp_error( $terms ) ) :
  38.                     $term_link = array();
  39.                     foreach ( $terms as $term ) {
  40.                         $term_link[] = $term->name;
  41.                     }                  
  42.                     $term_link = join( ", ", $term_link ); ?>
  43.             <h2><?php echo $term_link; ?></h2>
  44.             <?php endif; ?>
  45.         </div>
  46.     </div>
  47.     <?php elseif(!empty($parentpage) && !is_search()) :
  48.         $parentpage = get_template_link(get_post_type().".php");
  49.         $pagetitle_copy = get_option("ocmx_pagetitle_copy"); ?>
  50.         <div id="title-container">
  51.             <div class="title-block">
  52.                 <h2><?php echo $parentpage->post_title; ?></h2>
  53.                 <?php if($pagetitle_copy !="no") :
  54.                     if($parentpage->post_excerpt != '') : echo '<p>'.$parentpage->post_excerpt.'</p>'; endif;
  55.                 endif; ?>
  56.             </div>
  57.         </div>
  58.     <?php elseif( ( get_post_type() == "post" && is_category() ) || is_search() ) : ?>
  59.         <div id="title-container">
  60.             <div class="title-block">
  61.                 <h2><?php wp_title(''); ?></h2>
  62.                 <?php if($pagetitle_copy !="no") :
  63.                     echo category_description();
  64.                 endif; ?>
  65.             </div>
  66.         </div>
  67.     <?php elseif(get_post_type() == "post" && is_single()) :
  68.         $category = get_the_category();?>
  69.         <div id="title-container">
  70.             <div class="title-block">
  71.                 <h2><?php echo $category[0]->cat_name; ?></h2>
  72.                 <?php if($pagetitle_copy !="no") :
  73.                     echo category_description();
  74.                 endif; ?>
  75.             </div>
  76.         </div>
  77.     <?php else : ?>
  78.         <?php while ( have_posts() ) : the_post();
  79.             $header_bg_image = get_post_meta($post->ID, "header_image", true);
  80.             $header_bg_attributes = get_post_meta($post->ID, "header_image_attributes", true);
  81.             if($header_bg_image  != '' || !empty($header_bg_attributes["colour"]) || is_page()) : ?>
  82.             <div id="title-container">
  83.                 <div class="title-block">
  84.                     <h2><?php the_title(); ?></h2>
  85.                     <?php if($pagetitle_copy !="no") :
  86.                         // Check if we're using a real excerpt or the content
  87.                         if( $post->post_excerpt != "") :
  88.                             $excerpt = get_the_excerpt();
  89.                             $excerpttext = strip_tags( $excerpt );
  90.                         endif;
  91.                        
  92.                         // If the Excerpt exists, continue
  93.                         if(isset($excerpttext) && $excerpttext != "" ) :
  94.  
  95.                         // Use an ellipsis if the excerpt is longer than the count
  96.                             echo '<p>'.$excerpttext.'</p>';
  97.                         endif; 
  98.                     endif; ?>
  99.                 </div>
  100.             </div>
  101.         <?php endif;
  102.         endwhile; ?>
  103.     <?php endif;
  104. } ?>
  105.  
  106. <div id="crumbs-container">
  107.     <?php ocmx_breadcrumbs(); ?>
  108. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement