/** * Get the template type to apply for current page in: `full_width`, `full_width_offest`, `right_sidebar`, `left_sidebar` * * @uses is_active_sidebar() * @return false|string */ function get_template_type() { global $template_type; if (!isset($template_type)) { $current = get_page_template_slug(); if (!empty($current)) { $template_type = $current == 'default' ? get_basicbootstrap_mod('not_blog_pages_layout') : str_replace(array('page-templates/', '.php'), '', $current); } elseif (!is_blog_page()) { $template_type = get_basicbootstrap_mod('not_blog_pages_layout'); } else { $template_type = get_basicbootstrap_mod('blog_pages_layout'); } if (strpos($template_type, 'sidebar') !== false && !is_active_sidebar('primary-widget-area')) { $template_type = 'full_width'; } } return $template_type; }
<?php if (is_search() || is_archive()) { // Only display Excerpts for Search and Archive Pages ?> <div class="entry-summary col-md-12"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php } elseif (is_blog_page()) { ?> <div class="entry-summary col-md-12"> <?php get_template_part('posts', 'images'); ?> <?php the_content(__('Continue reading <span class="meta-nav">→</span>', 'pgb')); ?> </div><!-- .entry-content --> <?php
/** * Template for displaying post/page images * * @package pgb */ global $post; if (has_post_thumbnail($post->ID)) { $post_thumbnail_id = get_post_thumbnail_id($post->ID); $size = 'full'; $attr = array('class' => 'img-responsive center-block'); $alt_text = get_post_meta($post_thumbnail_id, '_wp_attachment_image_alt', true); ?> <?php if (is_blog_page() && $post_thumbnail_id) { // Blog or Featured Posts pages only ?> <div class="entry-image thumbnail alignleft col-xs-12 col-md-6"> <?php echo the_post_thumbnail($size, $attr); ?> <?php // Captions disabled on blog pages /* if ( ! empty( $alt_text ) ) { ?> <div class="caption"> <p class="text-center"><?php _e( $alt_text, 'pgb' ); ?></p>
} } return $singular_page_type; } /** * This will force the $page_type global to be set correctly while WP prepares its query * * The 'template_include' filter is documented in `wp-includes/template-load.php`. */ add_filter('template_include', function ($tpl) { global $page_type, $singular_page_type, $blog_page; unset($page_type); unset($singular_page_type); unset($blog_page); get_page_type(); is_blog_page(); get_singular_type(); return $tpl; }, 1000); // STICKY POSTS LOOPS /** * Check if current post is sticky and if it should be treated specially * * This returns `true` if the post is sticky for the following pages: * * - home / front page * - category */ function is_sticky_view() { global $sticky_view;
function get_page_layout() { if (is_page() || is_single()) { global $post; } $metabox_selection = $post ? get_post_meta($post->ID, THEMESLUG . 'custom_sidebar_position', true) ? get_post_meta($post->ID, THEMESLUG . 'custom_sidebar_position', true) : false : false; //fullwidth selection via metaboxes // site part = regular pages if (is_theme_page() || is_contact_page()) { $fullwidth = $metabox_selection; } // site part = blog if (is_blog_page()) { $fullwidth = $metabox_selection ? $metabox_selection == "full" ? "fullwidth" : false : get_option(THEMESLUG . '_sidebar_position_blog') == "full" ? "fullwidth" : false; } return $fullwidth; }
function pgb_rich_snippets() { global $post, $wp_query; $post_id = get_queried_object_id(); $post_object = get_post($post_id); /* Front Page */ if (is_front_page()) { $front_page_snippet = array("@context" => "http://schema.org", "@type" => get_option('rich_snippet_type', false) ? get_option('rich_snippet_type', 'WebSite') : 'WebSite', "url" => get_bloginfo('url'), "name" => get_bloginfo('name'), "logo" => pgb_get_logo(false)); if (pgb_includes_search()) { $page_includes_search = array("potentialAction" => array("@type" => "SearchAction", "target" => get_bloginfo('url') . "/?s={search}", "query-input" => "required name=search")); $front_page_snippet = array_merge($front_page_snippet, $page_includes_search); } pgb_print_snippet($front_page_snippet); } elseif (is_search()) { $search_page_snippet = array("@context" => "http://schema.org", "@type" => "SearchResultsPage", "url" => get_search_link(), "mainEntityOfPage" => array("@type" => "SearchAction", "query" => get_search_query())); pgb_print_snippet($search_page_snippet); } elseif (is_blog_page()) { $blog_page_snippet = array("@type" => 'Blog', "url" => get_permalink($post_id), "BlogPost" => array()); if (have_posts()) { while (have_posts()) { the_post(); $blog_page_snippet["BlogPost"][] = array("@type" => "BlogPosting", "headline" => get_the_title(), "datePublished" => get_the_date("Y-m-d\\TH:i:sP"), "articleBody" => wp_strip_all_tags(get_the_content())); } } pgb_print_snippet($blog_page_snippet); } /* Blog Post */ if (is_single()) { $single_post_snippet = array("@type" => 'BlogPosting', "url" => get_permalink($post_id), "headline" => get_the_title($post_id), "datePublished" => get_the_date("Y-m-d\\TH:i:sP", $post_id), "articleBody" => wp_strip_all_tags($post_object->post_content), "author" => get_the_author_meta('user_nicename', $post_object->post_author)); if (has_post_thumbnail($post_id)) { $post_thumbnail_id = get_post_thumbnail_id($post_id); $post_thumbnail = get_post($post_thumbnail_id); $image_snippet = array("image" => array("@type" => "ImageObject", "contentUrl" => wp_get_attachment_url($post_thumbnail_id), "datePublished" => $post_thumbnail->post_date, "description" => $post_thumbnail->post_content, "name" => $post_thumbnail->post_title)); $single_post_snippet = array_merge($single_post_snippet, $image_snippet); } pgb_print_snippet($single_post_snippet); } }
if ($video) { $button = "play"; $media_link = $video; } else { $media_link = $image; $button = "magnifier"; } ?> <div class="box portfolio one box-shadow" id="<?php echo $post_uniqueID; ?> "> <!-- page title --> <?php if (!is_front_page() && !is_blog_page()) { ?> <!-- page title --> <div class="head_text"> <div class="arrow"></div><!-- arrow --> <h2><?php the_title(); ?> </h2> </div> <!-- /page title --> <?php } ?> <?php
function blog_page_id() { if (is_blog_page() && get_option('page_for_posts')) { $blog_page_id = get_option('page_for_posts'); } return $blog_page_id; }