/** * Displays navigation to next/previous post when applicable. * * @since Twenty Thirteen 1.0 * * @return void */ function activetheme_post_nav() { global $post; // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post($post->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <?php /* <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'activetheme' ); ?></h1> */ ?> <div class="nav-links clearfix"> <?php if (is_singular('article')) { previous_post_link('%link', _x('<span class="meta-nav meta-nav-prev">←</span> Previous Article', 'Previous article link', 'activetheme')); next_post_link('%link', _x('Next Article <span class="meta-nav meta-nav-next">→</span>', 'Next article link', 'activetheme')); } else { previous_post_link('%link', _x('<span class="meta-nav meta-nav-prev">←</span> Previous Post', 'Previous post link', 'activetheme')); next_post_link('%link', _x('Next Post <span class="meta-nav meta-nav-next">→</span>', 'Next post link', 'activetheme')); } ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
/** * Add featured image as background image to post navigation elements. * * @since Foundation Theme 0.5.0 * * @see wp_add_inline_style() */ function foundation_post_nav_background() { if (!is_single()) { return; } $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); $css = ''; if (is_attachment() && 'attachment' == $previous->post_type) { return; } if ($previous && has_post_thumbnail($previous->ID)) { $prevthumb = wp_get_attachment_image_src(get_post_thumbnail_id($previous->ID), 'post-thumbnail'); $css .= ' .post-navigation .nav-previous { background-image: url(' . esc_url($prevthumb[0]) . '); } .post-navigation .nav-previous .post-title, .post-navigation .nav-previous a:hover .post-title, .post-navigation .nav-previous .meta-nav { color: #fff; } .post-navigation .nav-previous a:before { background-color: rgba(0, 0, 0, 0.4); } '; } if ($next && has_post_thumbnail($next->ID)) { $nextthumb = wp_get_attachment_image_src(get_post_thumbnail_id($next->ID), 'post-thumbnail'); $css .= ' .post-navigation .nav-next { background-image: url(' . esc_url($nextthumb[0]) . '); border-top: 0; } .post-navigation .nav-next .post-title, .post-navigation .nav-next a:hover .post-title, .post-navigation .nav-next .meta-nav { color: #fff; } .post-navigation .nav-next a:before { background-color: rgba(0, 0, 0, 0.4); } '; } wp_add_inline_style('main-stylesheet', $css); }
/** * Display navigation to next/previous post when applicable. * * @return void */ function my_simone_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <div class="post-nav-box clear"> <h1 class="screen-reader-text"><?php _e('Post navigation', 'my-simone'); ?> </h1> <div class="nav-links"> <?php previous_post_link('<div class="nav-previous"><div class="nav-indicator">' . _x('Previous Post:', 'Previous post', 'my-simone') . '</div><h1>%link</h1></div>', '%title'); next_post_link('<div class="nav-next"><div class="nav-indicator">' . _x('Next Post:', 'Next post', 'my-simone') . '</div><h1>%link</h1></div>', '%title'); ?> </div><!-- .nav-links --> </div><!-- .post-nav-box --> </nav><!-- .navigation --> <?php }
/** * Display navigation to next/previous post when applicable. */ function uncode_post_navigation($index_btn = '') { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } $output = '<nav class="post-navigation" role="navigation"> <ul class="navigation">'; $prev = get_previous_post_link('<li class="page-prev"><span class="btn-container">%link</span></li>', '<i class="fa fa-angle-left"></i><span>' . esc_html__('Prev', 'uncode') . '</span>'); if ($prev !== '') { $output .= $prev; } else { $output .= '<li class="page-prev"><span class="btn-container"><span class="btn btn-link btn-icon-left btn-disable-hover"><i class="fa fa-angle-left"></i>' . esc_html__('Prev', 'uncode') . '</span></span></li>'; } if ($index_btn !== '') { $output .= '<li class="nav-back"><span class="btn-container">' . $index_btn . '</span></li>'; } $next = get_next_post_link('<li class="page-next"><span class="btn-container">%link</span></li>', '<span>' . esc_html__('Next', 'uncode') . '</span><i class="fa fa-angle-right"></i>'); if ($next !== '') { $output .= $next; } else { $output .= '<li class="page-next"><span class="btn-container"><span class="btn btn-link btn-icon-right btn-disable-hover">' . esc_html__('Next', 'uncode') . '<i class="fa fa-angle-right"></i></span></span></li>'; } $output .= '</ul><!-- .navigation --> </nav><!-- .post-navigation -->'; return $output; }
function flat_post_nav() { global $post; $previous = is_attachment() ? get_post($post->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e('Post navigation', 'flat'); ?> </h1> <div class="nav-links"> <?php previous_post_link('%link', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'flat')); ?> <?php next_post_link('%link', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'flat')); ?> </div> </nav> <?php }
function zilla_content_width() { if (is_page_template('template-full-width.php') || is_attachment()) { global $content_width; $content_width = 940; } }
/** * Display navigation to next/previous post when applicable. */ function oceanic_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e('Post navigation', 'oceanic'); ?> </h1> <div class="nav-links"> <?php $slider_cats = get_theme_mod('oceanic-slider-cats', false); $slider_cat_ids = array(); if ($slider_cats) { $slider_cats = explode(',', esc_html($slider_cats)); for ($i = 0; $i < count($slider_cats); ++$i) { $cat_id = get_cat_ID($slider_cats[$i]); if ($cat_id > 0) { $slider_cat_ids[$i] = $cat_id; } } } previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'oceanic'), false, $slider_cat_ids); next_post_link('<div class="nav-next">%link</div>', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'oceanic'), false, $slider_cat_ids); ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
/** * Display breadcrumbs */ public function display() { if (Habakiri::get('is_displaying_bread_crumb') === 'false') { return; } global $wp_query; // Set to home $home_label = $this->get_home_label(); $this->set($home_label, home_url('/')); // Set to blog $post_type = $this->get_post_type(); if (is_category() || is_tag() || is_date() || is_author() || is_single() && $post_type === 'post') { $show_on_front = get_option('show_on_front'); $page_for_posts = get_option('page_for_posts'); if ($show_on_front === 'page' && $page_for_posts) { $this->set(get_the_title($page_for_posts), get_permalink($page_for_posts)); } } // Set current and ancestors if (is_404()) { $this->set_for_404(); } elseif (is_search()) { $this->set_for_search(); } elseif (is_tax()) { $this->set_for_tax(); } elseif (is_attachment()) { $this->set_for_attachment(); } elseif (is_page() && !is_front_page()) { $this->set_for_page(); } elseif (is_post_type_archive()) { $this->set_for_post_type_archive(); } elseif (is_single()) { $this->set_for_single(); } elseif (is_category()) { $this->set_for_category(); } elseif (is_tag()) { $this->set_for_tag(); } elseif (is_author()) { $this->set_for_author(); } elseif (is_day()) { $this->set_for_day(); } elseif (is_month()) { $this->set_for_month(); } elseif (is_year()) { $this->set_for_year(); } elseif (is_home() && !is_front_page()) { $this->set_for_blog(); } $bread_crumb = array(); $last_item = array_pop($this->bread_crumb); foreach ($this->bread_crumb as $_bread_crumb) { if (!empty($_bread_crumb['link'])) { $bread_crumb[] = sprintf('<a href="%s">%s</a>', esc_url($_bread_crumb['link']), esc_html($_bread_crumb['title'])); } else { $bread_crumb[] = esc_html($_bread_crumb['title']); } } $bread_crumb[] = sprintf('<strong>%s</strong>', $last_item['title']); printf('<div class="breadcrumbs">%s</div>', implode(' > ', apply_filters('habakiri_bread_crumb', $bread_crumb))); }
/** * Display navigation to next/previous post when applicable. * * @return void */ function writ_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e('Post navigation', 'writ'); ?> </h1> <div class="nav-links"> <?php previous_post_link('<div class="nav-previous">%link</div>', '<div class="arrow">' . _x('←', 'Previous post link', 'writ') . '</div><div class="link">%title</div>'); ?> <?php next_post_link('<div class="nav-next">%link</div>', '<div class="arrow">' . _x('→', 'Next post link', 'writ') . '</div><div class="link">%title</div>'); ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
function getWpTemplate() { if (defined('WP_USE_THEMES') && WP_USE_THEMES) { $template = false; if (is_404() && ($template = get_404_template())) { } elseif (is_search() && ($template = get_search_template())) { } elseif (is_tax() && ($template = get_taxonomy_template())) { } elseif (is_front_page() && ($template = get_front_page_template())) { } elseif (is_home() && ($template = get_home_template())) { } elseif (is_attachment() && ($template = get_attachment_template())) { } elseif (is_single() && ($template = get_single_template())) { } elseif (is_page() && ($template = get_page_template())) { } elseif (is_category() && ($template = get_category_template())) { } elseif (is_tag() && ($template = get_tag_template())) { } elseif (is_author() && ($template = get_author_template())) { } elseif (is_date() && ($template = get_date_template())) { } elseif (is_archive() && ($template = get_archive_template())) { } elseif (is_comments_popup() && ($template = get_comments_popup_template())) { } elseif (is_paged() && ($template = get_paged_template())) { } else { $template = get_index_template(); } return str_replace(ABSPATH, '', $template); } else { return null; } }
function dln_template_blank_page() { if (is_page_template('page-templates/blank-page.php') || is_attachment() || !is_active_sidebar('sidebar-1')) { global $content_width; $content_width = 960; } }
function wpforge_adjust_content_width() { global $content_width; if (is_page_template('full-width.php') || is_page_template('front-page.php') || is_attachment() || !is_active_sidebar('sidebar-1')) { $content_width = 1024; } }
/** * Display navigation to next/previous post when applicable. * * @return void */ function apostrophe_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text"><?php esc_html_e('Post navigation', 'apostrophe'); ?> </h1> <div class="nav-links"> <div class="nav-previous"> <?php previous_post_link('%link', '<span class="meta-nav">' . _x('Previous', 'Previous post link', 'apostrophe') . '</span> <span class="apostrophe-post-title">%title</span>'); ?> </div> <div class="nav-next"> <?php next_post_link('%link', '<span class="meta-nav">' . _x('Next', 'Next post link', 'apostrophe') . '</span> <span class="apostrophe-post-title">%title</span>'); ?> </div> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
/** * Display navigation to next/previous post when applicable. * * @todo Remove this function when WordPress 4.3 is released. */ function the_post_navigation() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <h2 class="screen-reader-text"><?php _e('Post navigation', 'ncssm_sg'); ?> </h2> <div class="nav-links"> <?php previous_post_link('<div class="nav-previous">%link</div>', '%title'); next_post_link('<div class="nav-next">%link</div>', '%title'); ?> </div> <!-- .nav-links --> </nav><!-- .navigation --> <?php }
/** * Adds a pretty "Continue Reading" link to custom post excerpts. */ function bootstrapthreeminimal_custom_excerpt_more($output) { if (has_excerpt() && !is_attachment()) { $output .= bootstrapthreeminimal_continue_reading_link(); } return $output; }
/** * Display navigation to next/previous post when applicable. * * @return void */ function homeword_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <h1 class="assistive-text"><?php _e('Post navigation', 'homeword'); ?> </h1> <div class="nav-links"> <?php previous_post_link('%link', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'homeword')); ?> <?php next_post_link('%link', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'homeword')); ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
function sfc_media_find_images($post, $content = '') { if (empty($content)) { $content = apply_filters('the_content', $post->post_content); } $images = array(); // we get the post thumbnail, put it first in the image list if (current_theme_supports('post-thumbnails') && has_post_thumbnail($post->ID)) { $thumbid = get_post_thumbnail_id($post->ID); $att = wp_get_attachment_image_src($thumbid, 'full'); if (!empty($att[0])) { $images[] = $att[0]; } } if (is_attachment() && preg_match('!^image/!', get_post_mime_type($post))) { $images[] = wp_get_attachment_url($post->ID); } // now search for images in the content itself if (preg_match_all('/<img\\s+(.+?)>/i', $content, $matches)) { foreach ($matches[1] as $match) { foreach (wp_kses_hair($match, array('http')) as $attr) { $img[strtolower($attr['name'])] = $attr['value']; } if (isset($img['src'])) { if (!isset($img['class']) || isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude', array('wp-smiley')))) { // ignore smilies if (!in_array($img['src'], $images) && strpos($img['src'], 'fbcdn.net') === false && strpos($img['src'], '/plugins/') === false) { $images[] = $img['src']; } } } } } return $images; }
/** * Display navigation to next/previous post when applicable. * * @deprecated 2.1 Use the_post_navigation() */ function blue_planet_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text"><?php esc_html_e('Post navigation', 'blue-planet'); ?> </h1> <div class="nav-links"> <?php previous_post_link('%link', '<span class="meta-nav">←</span> %title'); ?> <?php next_post_link('%link', '%title <span class="meta-nav">→</span>'); ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
function selenenw_post_thumbnail() { if (post_password_required() || is_attachment() || !has_post_thumbnail()) { return; } if (is_singular()) { ?> <div class="entry-featured"> <?php the_post_thumbnail(); ?> </div><!-- .post-thumbnail --> <?php } else { ?> <figure> <a href="<?php the_permalink(); ?> "> <?php the_post_thumbnail('post-thumbnail', array('alt' => get_the_title())); ?> </a> </figure> <?php } // End is_singular() }
/** * Adjusts content_width value for few pages and attachment templates. */ function sela_content_width() { global $content_width; if (is_page_template('page-templates/full-width-page.php') || is_page_template('page-templates/grid-page.php') || is_attachment() || !is_active_sidebar('sidebar-1')) { $content_width = 778; } }
/** * Display navigation to next/previous post when applicable. * * @todo Remove this function when WordPress 4.3 is released. */ function tutannet_post_navigation() { $trans_next = of_get_option('trans_next_article'); if (empty($trans_next)) { $trans_next = __('Next article', 'tutannet'); } $trans_prev = of_get_option('trans_previous_article'); if (empty($trans_prev)) { $trans_prev = __('Previous article', 'tutannet'); } // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation clearfix" role="navigation"> <h2 class="screen-reader-text"><?php _e('Post navigation', 'tutannet'); ?> </h2> <div class="nav-links"> <?php previous_post_link('<div class="nav-previous"><div class="link-caption"><i class="fa fa-angle-left"></i>' . esc_attr($trans_prev) . '</div>%link</div>', '%title'); next_post_link('<div class="nav-next"><div class="link-caption">' . esc_attr($trans_next) . '<i class="fa fa-angle-right"></i></div>%link</div>', '%title'); ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
/** * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. */ function airmozilla_custom_excerpt_more($output) { if (has_excerpt() && !is_attachment()) { $output .= airmozilla_continue_reading_link(); } return $output; }
function mighty_content_width() { if (is_page_template('template-homepage.php') || is_page_template('template-full-width.php') || is_singular('portfolio') || is_attachment()) { global $content_width; $content_width = 980; } }
/** * Theme post thumbnail. ** Wraps the post thumbnail in an anchor element on index * views, or a div element when on single views. */ function mk_post_thumbnail() { if (post_password_required() || is_attachment() || !has_post_thumbnail()) { return; } if (is_singular()) { ?> <div class="post-thumbnail"> <?php the_post_thumbnail('mk-wide'); ?> </div> <?php } else { ?> <a class="post-thumbnail" href="<?php the_permalink(); ?> " aria-hidden="true"> <?php the_post_thumbnail('mk-wide'); ?> </a> <?php } // End is_singular() }
/** * returns the language based on the queried content * * @since 1.2 * * @return object|bool detected language, false if none was found */ protected function get_language_from_content() { // no language set for 404 if (is_404() || is_attachment() && !$this->options['media_support']) { return $this->get_preferred_language(); } if ($var = get_query_var('lang')) { $lang = explode(',', $var); $lang = $this->model->get_language(reset($lang)); // choose the first queried language } elseif ((is_single() || is_page() || is_attachment() && $this->options['media_support']) && (($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) || ($var = get_query_var('attachment_id')))) { $lang = $this->model->post->get_language($var); } else { foreach ($this->model->get_translated_taxonomies() as $taxonomy) { if ($var = get_query_var(get_taxonomy($taxonomy)->query_var)) { $lang = $this->model->term->get_language($var, $taxonomy); } } } /** * Filter the language before it is set from the content * * @since 0.9 * * @param bool|object $lang language object or false if none was found */ return apply_filters('pll_get_current_language', isset($lang) ? $lang : false); }
/** * The default template for displaying content * * Used for both single and index/archive/search. * * @package WordPress * @subpackage Twenty_Fifteen * @since Twenty Fifteen 1.0 */ function twentyfifteen_post_thumbnail() { if (post_password_required() || is_attachment() || !has_post_thumbnail()) { return; } if (is_singular()) { ?> <div class="post-thumbnail"> <?php the_post_thumbnail(); ?> </div><!-- .post-thumbnail --> <?php } else { ?> <a class="post-thumbnail" href="<?php the_permalink(); ?> " aria-hidden="true"> <?php the_post_thumbnail('post-thumbnail', array('alt' => get_the_title())); ?> </a> <?php } // End is_singular() }
/** * Display navigation to next/previous post when applicable. */ function zerif_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation"> <h2 class="screen-reader-text"><?php _e('Post navigation', 'zerif-lite'); ?> </h2> <div class="nav-links"> <?php previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'zerif-lite')); next_post_link('<div class="nav-next">%link</div>', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'zerif-lite')); ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
/** * Adjust the content_width for the pages and single image attachment templates. * * @since 1.0 * * @return void */ function zilla_content_width() { if (is_page() || is_attachment()) { global $content_width; $content_width = 1160; } }
/** * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. */ function minileven_custom_excerpt_more($output) { if (has_excerpt() && !is_attachment()) { $output .= minileven_continue_reading_link(); } return $output; }
/** * Display navigation to next/previous post when applicable. * * @since Twenty Fourteen 1.0 * * @return void */ function twentyfourteen_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e('Post navigation', 'twentyfourteen'); ?> </h1> <div class="nav-links"> <?php if (is_attachment()) { previous_post_link('%link', __('<span class="meta-nav">Published In</span>%title', 'twentyfourteen')); } else { previous_post_link('%link', __('<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen')); next_post_link('%link', __('<span class="meta-nav">Next Post</span>%title', 'twentyfourteen')); } ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }