function presscore_search_title_shortcode() { $title = ''; $wrap_class = ''; if (is_search()) { $title = get_search_query(); } else { if (is_archive()) { if (is_category()) { $title = single_cat_title('', false); } elseif (is_tag()) { $title = single_tag_title('', false); } elseif (is_author()) { the_post(); $title = '<a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta("ID"))) . '" title="' . esc_attr(get_the_author()) . '" rel="me">' . get_the_author() . '</a>'; $wrap_class .= ' vcard'; rewind_posts(); } elseif (is_day()) { $title = '<span>' . get_the_date() . '</span>'; } elseif (is_month()) { $title = '<span>' . get_the_date('F Y'); } elseif (is_year()) { $title = '<span>' . get_the_date('Y'); } elseif (is_tax('dt_portfolio_category')) { $title = single_term_title('', false); } elseif (is_tax('dt_gallery_category')) { $title = single_term_title('', false); } } } if ($title) { $title = '<span' . ($wrap_class ? ' class="' . esc_attr($wrap_class) . '"' : '') . '>' . $title . '</span>'; } return $title; }
function description() { if (is_home() || is_front_page()) { echo trim(of_get_option('site_description')); } elseif (is_category()) { $description = strip_tags(category_description()); echo trim($description); } elseif (is_single()) { if (get_the_excerpt()) { echo get_the_excerpt(); } else { global $post; $description = trim(str_replace(array("\r\n", "\r", "\n", " ", " "), " ", str_replace("\"", "'", strip_tags($post->post_content)))); echo mb_substr($description, 0, 220, 'utf-8'); } } elseif (is_search()) { echo '“'; the_search_query(); echo '”为您找到结果 '; global $wp_query; echo $wp_query->found_posts; echo ' 个'; } elseif (is_tag()) { $description = strip_tags(tag_description()); echo trim($description); } else { $description = strip_tags(term_description()); echo trim($description); } }
function changept() { if (is_category() && !is_admin()) { set_query_var('post_type', array('post', 'category')); } return; }
/** * Title filter */ function mediamaven_filter_wp_title($old_title, $sep, $sep_location) { $site_name = get_bloginfo('name'); $site_description = get_bloginfo('description'); // add padding to the sep $ssep = ' ' . $sep . ' '; if ($site_description && (is_home() || is_front_page())) { return $site_name . ' | ' . $site_description; } else { // find the type of index page this is if (is_category()) { $insert = $ssep . __('Kategorija', 'media-maven'); } elseif (is_tag()) { $insert = $ssep . __('Žymos', 'media-maven'); } elseif (is_author()) { $insert = $ssep . __('Autorius', 'media-maven'); } elseif (is_year() || is_month() || is_day()) { $insert = $ssep . __('Archyvai', 'media-maven'); } else { $insert = NULL; } // get the page number we're on (index) if (get_query_var('paged')) { $num = $ssep . __('Page ', 'media-maven') . get_query_var('paged'); } elseif (get_query_var('page')) { $num = $ssep . __('Page ', 'media-maven') . get_query_var('page'); } else { $num = NULL; } // concoct and return new title return $site_name . $insert . $old_title . $num; } }
function homeType($classes) { // Add the class when needed $HomebgType = get_option('_tdCore-home-bgType'); $iC = ''; $end = ''; foreach (get_the_category() as $category) { $postcat = $category->cat_ID; $catname = $category->cat_name; $catslug = $category->category_nicename; if (is_category($catslug)) { $end = $postcat; } } $args = array('orderby' => 'name', 'order' => 'ASC'); $categories = get_categories($args); foreach ($categories as $cat) { $iC++; if ($cat->name != '') { if ($end == $cat->cat_ID) { $catname = $cat->name; $count = get_option('portfolioType' . $iC); $count = strtolower($count); $classes[] = 'body-' . $count; } } } if (is_front_page()) { $classes[] = 'body-' . $HomebgType; } return $classes; }
public function check_language_code_in_url() { global $wp_query, $post; if (is_single() || is_page()) { if (isset($post->ID) && $this->model->is_translated_post_type($post->post_type)) { $language = $this->model->get_post_language((int) $post->ID); } } elseif (is_category() || is_tag() || is_tax()) { $obj = $wp_query->get_queried_object(); if ($this->model->is_translated_taxonomy($obj->taxonomy)) { $language = $this->model->get_term_language((int) $obj->term_id); } } elseif ($wp_query->is_posts_page) { $obj = $wp_query->get_queried_object(); $language = $this->model->get_post_language((int) $obj->ID); } // the language is not correctly set so let's redirect to the correct url for this object if (!empty($language)) { $requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $redirect_url = $this->links_model->switch_language_in_link($requested_url, $language); if ($requested_url != $redirect_url) { wp_redirect($redirect_url, 301); exit; } } }
function mypace_custom_navi_menu($classes, $item) { global $wp_query; $singular_slug = 'service'; $page_for_custom_type_title = 'サービス'; $page_for_posts = get_option('page_for_posts'); $post_type_query = $wp_query->query_vars['post_type']; $del_flag = true; $add_flag = false; if (is_singular('post') || is_category() || is_tag()) { $del_flag = false; } elseif (is_author() || is_date() || is_author()) { if (in_array($post_type_query, array('', 'post'))) { $del_flag = false; } elseif ($post_type_query == $custom_post_type) { $add_flag = true; } } elseif (is_tax()) { $taxonomy = get_taxonomy($wp_query->query_vars['taxonomy']); if (count($taxonomy->object_type) == 1 && $taxonomy->object_type[0] == 'post') { $del_flag = false; } elseif (count($taxonomy->object_type) == 1 && $taxonomy->object_type[0] == $singular_slug) { $add_flag = true; } } elseif (is_singular($singular_slug)) { $add_flag = true; } if ($del_flag && is_numeric($page_for_posts) && $item->object_id == $page_for_posts && $item->object == 'page' && ($key = array_search('current_page_parent', $classes))) { unset($classes[$key]); } elseif ($add_flag && $item->title == $page_for_custom_type_title && $item->object == 'page') { $classes[] = 'current_page_parent'; } return $classes; }
/** * Shim for `sociallyviral_archive_title()`. * * Display the archive title based on the queried object. * * @todo Remove this function when WordPress 4.3 is released. * * @param string $before Optional. Content to prepend to the title. Default empty. * @param string $after Optional. Content to append to the title. Default empty. */ function sociallyviral_archive_title($before = '', $after = '') { if (is_category()) { $title = sprintf(__('Category: %s', 'sociallyviral'), single_cat_title('', false)); } elseif (is_tag()) { $title = sprintf(__('Tag: %s', 'sociallyviral'), single_tag_title('', false)); } elseif (is_author()) { $title = sprintf(__('Author: %s', 'sociallyviral'), '<span class="vcard">' . get_the_author() . '</span>'); } elseif (is_year()) { $title = sprintf(__('Year: %s', 'sociallyviral'), get_the_date(_x('Y', 'yearly archives date format', 'sociallyviral'))); } elseif (is_month()) { $title = sprintf(__('Month: %s', 'sociallyviral'), get_the_date(_x('F Y', 'monthly archives date format', 'sociallyviral'))); } elseif (is_day()) { $title = sprintf(__('Day: %s', 'sociallyviral'), get_the_date(_x('F j, Y', 'daily archives date format', 'sociallyviral'))); } elseif (is_post_type_archive()) { $title = sprintf(__('Archives: %s', 'sociallyviral'), post_type_archive_title('', false)); } elseif (is_tax()) { $tax = get_taxonomy(get_queried_object()->taxonomy); /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ $title = sprintf(__('%1$s: %2$s', 'sociallyviral'), $tax->labels->singular_name, single_term_title('', false)); } else { $title = __('Archives', 'sociallyviral'); } /** * Filter the archive title. * * @param string $title Archive title to be displayed. */ $title = apply_filters('get_the_archive_title', $title); if (!empty($title)) { echo $before . $title . $after; } }
function kb_scripts() { wp_enqueue_style('Google-Fonts', 'https://fonts.googleapis.com/css?family=Roboto:300,400|Open+Sans:400,600,700'); wp_enqueue_style('Normalizer', get_template_directory_uri() . '/normalize.css'); wp_enqueue_style('Chosen', get_template_directory_uri() . '/chosen/chosen.css'); wp_enqueue_style('Dropzone', get_template_directory_uri() . '/css/dropzone.css'); wp_enqueue_style('Main', get_stylesheet_uri(), array(), '1.01', false); wp_enqueue_script('bx-js', get_template_directory_uri() . '/js/jquery.bxslider.min.js', array('jquery'), '1.0.1', true); wp_enqueue_script('easing-js', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array('jquery'), '1.0.1', true); wp_enqueue_script('chosen-js', get_template_directory_uri() . '/js/chosen.jquery.min.js', array('jquery'), '1.0.1', true); wp_enqueue_script('custom-js', get_template_directory_uri() . '/js/custom.js', array('jquery'), '1.0.1', true); if (is_page_template(array('page-create-basic-listing.php', 'page-edit-basic-listing.php', 'page-create-paid-listing.php', 'page-edit-paid-listing.php', 'page-create-basic-listing-fr.php', 'page-edit-basic-listing-fr.php', 'page-create-paid-listing-fr.php', 'page-edit-paid-listing-fr.php'))) { wp_enqueue_script('dropzone', get_template_directory_uri() . '/js/dropzone.js', array('jquery'), '1.0.1', 'true'); } // if(is_page_template(array('page-create-paid-listing.php', 'page-edit-paid-listing.php'))) { // wp_enqueue_script('stripejs', 'https://js.stripe.com/v2/', array(''), '1.0.1', 'false'); // } if (is_page_template('page-paid-listing.php')) { wp_register_script('googlemap', 'https://maps.google.com/maps/api/js?sensor=false', 'jquery'); wp_enqueue_script('googlemap'); } if (!is_admin()) { wp_localize_script('custom-js', 'my_ajax', array('ajaxurl' => admin_url('admin-ajax.php'))); } if (is_home() || is_category() || is_archive()) { wp_enqueue_script('blog-js', get_template_directory_uri() . '/js/ajax-blog.js', array('jquery'), '1.0.1', true); global $wp_query; // What page are we on? And what is the pages limit? $max = $wp_query->max_num_pages; $paged = get_query_var('paged') > 1 ? get_query_var('paged') : 1; // Add some parameters for the JS. wp_localize_script('blog-js', 'pbd_alp', array('startPage' => $paged, 'maxPages' => $max, 'nextLink' => next_posts($max, false))); } }
function get_breadcrumbs($post) { echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=" . get_bloginfo('url') . " itemprop=\"url\"><span itemprop=\"title\">Home</span></a><span class=arrow> > </span></li>"; if (is_home()) { $breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_post_title($page->ID) . '</span></a><span class=arrow> > </span></li>'; } elseif (is_single() || is_page()) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . get_the_title($page->ID) . '</span></a><span class=arrow> > </span></li>'; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb) { echo $crumb; } echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><span itemprop=\"title\">" . $post->post_title . "</span></li>"; } elseif (is_category()) { echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_cat_title($page->ID) . '</span></a></li>'; } elseif (is_archive()) { echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">Archives</span></li>'; } elseif (is_404()) { echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">404 Page Not Found</span></li>'; } }
function wcr_default_category_title($headline, $term) { if ((is_category() || is_tag()) && empty($headline)) { $headline = $term->name; } return $headline; }
function semifolio_filter_wp_title($old_title, $sep, $sep_location) { // add padding to the sep $ssep = ' ' . $sep . ' '; // find the type of index page this is if (is_category()) { $insert = $ssep . __('Category', 'slaves'); } elseif (is_tag()) { $insert = $ssep . __('Tag', 'slaves'); } elseif (is_author()) { $insert = $ssep . __('Author', 'slaves'); } elseif (is_year() || is_month() || is_day()) { $insert = $ssep . __('Archives', 'slaves'); } elseif (is_home()) { $insert = $ssep . bloginfo('description'); } else { $insert = NULL; } // get the page number we're on (index) if (get_query_var('paged')) { $num = $ssep . __('Page ', 'slaves') . get_query_var('paged'); } elseif (get_query_var('page')) { $num = $ssep . __('Page ', 'slaves') . get_query_var('page'); } else { $num = NULL; } // concoct and return new title return bloginfo('name') . $insert . $old_title . $num; }
/** * 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))); }
function get_index_headline() { if (is_home()) { $index_headline = 'Blog Index'; } else { if (is_category()) { $category = single_term_title("", false); $index_headline = 'Archives for the "' . $category . '" Category'; } elseif (is_tag()) { $tag = single_term_title("", false); $index_headline = 'Archives for the "' . $tag . '" Category'; } elseif (is_day()) { $index_headline = 'Archive for ' . get_the_time('F jS, Y'); } elseif (is_month()) { $index_headline = 'Archive for ' . get_the_time('F Y'); } elseif (is_year()) { $index_headline = 'Archive for ' . get_the_time('Y'); } elseif (is_author()) { $index_headline = 'Author Archive'; } else { $index_headline = 'Blog Archives'; } } return $index_headline; }
public function tags() { if (!did_action('pre_get_posts')) { return array(); } $queried_object = get_queried_object(); $tags = array(); $default_tags = array('og:type' => 'website', 'og:locale' => get_locale(), 'og:site_name' => get_bloginfo('name'), 'og:image' => $this->get_image_url()); if (is_front_page()) { $tags = array('og:url' => home_url('/'), 'og:title' => get_bloginfo('name'), 'og:description' => get_bloginfo('description')); } else { if (is_singular()) { $tags = array('og:type' => 'article', 'og:url' => get_permalink($queried_object), 'og:title' => get_the_title($queried_object), 'og:description' => $this->generate_preview($queried_object->post_content), 'article:published_time' => date('c', strtotime($queried_object->post_date_gmt)), 'article:modified_time' => date('c', strtotime($queried_object->post_modified_gmt)), 'article:author' => get_author_posts_url($queried_object->post_author)); } else { if (is_tax() || is_category() || is_tag()) { $tags = array('og:url' => get_term_link($queried_object), 'og:title' => $queried_object->name, 'og:description' => $this->generate_preview($queried_object->description)); } else { if (is_author()) { $tags = array('og:type' => 'profile', 'og:url' => get_author_posts_url($queried_object->ID), 'og:title' => $queried_object->display_name, 'og:description' => $this->generate_preview($queried_object->user_description), 'profile:first_name' => get_the_author_meta('first_name', $queried_object->ID), 'profile:last_name' => get_the_author_meta('last_name', $queried_object->ID)); } } } } $tags = array_merge($default_tags, $tags); return apply_filters('appthemes_open_graph_meta_tags', $tags); }
function woocommerce_category_archive_description() { if (is_tax(array('product_cat', 'product_tag')) && get_query_var('paged') == 0) { $description = wc_format_content(term_description()); $image = false; if (is_tax() || is_tag() || is_category()) { $term = get_queried_object(); $thumbnail_id = absint(get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true)); if ($thumbnail_id) { $image = wp_get_attachment_image($thumbnail_id, 250); } else { $image = wc_placeholder_img_src(); } } if ($description) { $string = '<div class="row margin-bottom">'; if ($image) { $string .= '<div class="col-sm-4 col-sm-push-8">' . $image . '</div>'; } $string .= '<div class="term-description col-sm-8'; if ($image) { $string .= ' col-sm-pull-4'; } $string .= '">' . $description . '</div></div>'; echo $string; } } }
function render($atts, $content = null) { $atts['limit'] = 5; parent::render($atts); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query) if (is_category()) { // we have no related posts to display if ($this->td_query->post_count == 0) { return '<div class="td_line_above_cat_big_grid"> </div>'; } /** if we have posts in the big grid and we are on a category, do not show the default page no posts message. @see td_global::$custom_no_posts_message */ td_global::$custom_no_posts_message = false; } $buffy = ''; //output buffer //get the js for this block $buffy .= $this->get_block_js(); $buffy .= '<div class="' . $this->get_block_classes() . '">'; //get the block title $buffy .= $this->get_block_title(); //get the sub category filter for this block $buffy .= $this->get_pull_down_filter(); $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">'; $buffy .= $this->inner($this->td_query->posts); //inner content of the block $buffy .= '</div>'; //get the ajax pagination for this block $buffy .= $this->get_block_pagination(); $buffy .= '</div> <!-- ./block -->'; $buffy .= '<div class="clearfix"></div>'; return $buffy; }
/** * Gets the page type from WordPress. * * @return string A string representation of the current page type, * corresponding to the values used by publisherplugin.google.com. */ public static function getWordPressPageType() { // is_front_page() returns true if (1) a static front page is set and this // is that page, or (2) the front page is the blog home page and this // is the blog home page. if (is_front_page()) { return 'front'; } if (is_home()) { return 'home'; } if (is_single()) { return 'singlePost'; } if (is_page()) { return 'page'; } if (is_category()) { return 'category'; } if (is_archive()) { return 'archive'; } if (is_search()) { return 'search'; } if (is_404()) { return 'errorPage'; } return ''; }
function namespace_add_custom_types($query) { if (is_category() || is_tag() && empty($query->query_vars['suppress_filters'])) { $query->set('post_type', array('post', 'nav_menu_item', 'custom_type')); return $query; } }
/** * Check for a category archive. * * @param array $details Settings for the route */ private static function category(array $details) { if (is_category()) { self::loadController($details); exit; } }
function custom_intro() { echo "<div class='intro'>"; if (is_front_page()) { if (get_header_image()) { echo '<img class="header-image" src="' . esc_url(get_header_image()) . '" alt="' . get_bloginfo('description') . '" />'; } } else { // get title $id = get_option('page_for_posts'); if (is_day() || is_month() || is_year() || is_tag() || is_category() || is_singular('post') || is_home()) { $the_title = get_the_title($id); } else { $the_title = get_the_title(); } if (is_home() || is_singular('post')) { if (has_post_thumbnail($id)) { echo get_the_post_thumbnail($id, 'full'); } elseif (get_header_image()) { echo '<img class="header-image" src="' . esc_url(get_header_image()) . '" alt="' . $the_title . '" />'; } } elseif (has_post_thumbnail() && is_singular('page')) { the_post_thumbnail(); } elseif (get_header_image()) { echo '<img class="header-image" src="' . esc_url(get_header_image()) . '" alt="' . $the_title . '" />'; } } echo "</div>"; }
/** * Display a list categories * @param array $args * @return bool */ function zfwca_list_categories($args = array()) { $defaults = array('show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'exclude' => '', 'include' => '', 'exclude_tree' => '', 'current_category' => 0, 'taxonomy' => 'category'); $r = wp_parse_args($args, $defaults); $r['walker'] = new ZFWCA_Post_Category_Walker(); if (!isset($r['class'])) { $r['class'] = 'category' == $r['taxonomy'] ? 'categories' : $r['taxonomy']; } extract($r); if (!taxonomy_exists($taxonomy)) { return false; } $categories = get_categories($r); $output = ''; if (empty($categories)) { $output .= 'No categories'; } else { if (empty($r['current_category']) && (is_category() || is_tax() || is_tag())) { $current_term_object = get_queried_object(); if ($current_term_object && $r['taxonomy'] === $current_term_object->taxonomy) { $r['current_category'] = get_queried_object_id(); } } $output .= walk_category_tree($categories, 0, $r); } $output = apply_filters('zfwca_wp_list_categories', $output, $args); return $output; }
function porto_page_title() { global $porto_settings; $output = ''; if (!is_front_page()) { } elseif (is_home()) { $output .= $porto_settings['blog-title']; } if (is_singular()) { $output .= porto_page_title_leaf(); } else { if (is_post_type_archive()) { if (is_search()) { $output .= porto_page_title_leaf('search'); } else { $output .= porto_page_title_archive(); } } elseif (is_tax() || is_tag() || is_category()) { $html = porto_page_title_leaf('term'); if (is_tag()) { $output .= sprintf(__('Tag - %s', 'porto'), $html); } elseif (is_tax('product_tag')) { $output .= sprintf(__('Product Tag - %s', 'porto'), $html); } else { $output .= $html; } } elseif (is_date()) { if (is_year()) { $output .= porto_page_title_leaf('year'); } elseif (is_month()) { $output .= porto_page_title_leaf('month'); } elseif (is_day()) { $output .= porto_page_title_leaf('day'); } } elseif (is_author()) { $output .= porto_page_title_leaf('author'); } elseif (is_search()) { $output .= porto_page_title_leaf('search'); } elseif (is_404()) { $output .= porto_page_title_leaf('404'); } elseif (class_exists('bbPress') && is_bbpress()) { if (bbp_is_search()) { $output .= porto_page_title_leaf('bbpress_search'); } elseif (bbp_is_single_user()) { $output .= porto_page_title_leaf('bbpress_user'); } else { $output .= porto_page_title_leaf(); } } else { if (is_home() && !is_front_page()) { if (get_option('show_on_front') == 'page') { $output .= get_the_title(get_option('page_for_posts', true)); } else { $output .= $porto_settings['blog-title']; } } } } return apply_filters('porto_page_title', $output); }
/** * Wp in Progress * * @author WPinProgress * * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0) * It is also available at this URL: http://www.gnu.org/licenses/gpl-3.0.txt */ function novalite_get_title() { global $post; $title = get_the_title(); if (!empty($title)) { if (is_home() || is_category() || is_search()) { ?> <h3 class="title"> <a href="<?php echo get_permalink($post->ID); ?> "> <?php echo $title; ?> </a> </h3> <?php } else { ?> <h1 class="title"> <?php echo $title; ?> </h1> <?php } } }
function MyBreadcrumb() { if (!is_home()) { echo '<li><a href="'; echo get_option('home'); echo '/">'; echo 'Home'; echo '</a><span class="divider">/</span></li>'; if (is_category() || is_single()) { echo '<li>'; the_category(', ', '&title_li='); echo '<span class="divider">/</span></li>'; echo '</li>'; if (is_single()) { echo '<li class="active">'; // the_title(); echo '</li>'; } } elseif (is_page()) { echo '<li class="active">'; the_title(); echo '</li>'; } } }
function my_get_posts($query) { if (is_author() && $query->is_main_query() || is_category() && $query->is_main_query()) { $query->set('post_type', array('post', 'resources', 'news')); } return $query; }
/** * s2Member's Security Gate (protects WordPress content). * * @package s2Member\Security * @since 3.5 * * @attaches-to ``add_action("wp");`` * * @return null May redirect a browser *(exiting script execution)*, when/if content is NOT available to the current User/Member. */ public static function security_gate() { do_action("ws_plugin__s2member_before_security_gate", get_defined_vars()); if (is_category()) { // Categories & other inclusives. c_ws_plugin__s2member_catgs::check_catg_level_access(); } else { if (is_tag()) { // Post/Page Tags & other inclusives. c_ws_plugin__s2member_ptags::check_ptag_level_access(); } else { if (is_single()) { // All Posts & other inclusives. c_ws_plugin__s2member_posts::check_post_level_access(); } else { if (is_page()) { // All Pages & other inclusives. c_ws_plugin__s2member_pages::check_page_level_access(); } else { // Else, we simply look at URIs & other inclusives. c_ws_plugin__s2member_ruris::check_ruri_level_access(); } } } } do_action("ws_plugin__s2member_after_security_gate", get_defined_vars()); return; }
function widget($args, $instance) { global $wp_query; $facets = elasticsearch\Faceting::all(); $url = null; if (is_category() || is_tax()) { $url = get_term_link($wp_query->queried_object); } elseif (is_tag()) { $url = get_tag_link($wp_query->queried_object->term_id); } elseif (is_archive()) { $url = get_post_type_archive_link($wp_query->queried_object->query_var); } elseif (is_search()) { $url = home_url('/'); } foreach ($facets as $type => $facet) { if (count($facet['selected']) > 0) { $name = $type; if (taxonomy_exists($type)) { $name = get_taxonomy($type)->label; } echo '<aside id="facet-' . $type . '-selected" class="widget facets facets-selected">'; echo '<h3 class="widget-title">' . $name . '</h3>'; echo '<ul>'; foreach ($facet['selected'] as $option) { $url = elasticsearch\Faceting::urlRemove($url, $type, $option['slug']); echo '<li id="facet-' . $type . '-' . $option['slug'] . '" class="facet-item">'; echo '<a href="' . $url . '">' . $option['name'] . '</a>'; echo '</li>'; } echo '</ul>'; echo '</aside>'; } } }
function family_banner() { ?> <div class="banner"> <div class="wrap"> <?php if (is_front_page()) { family_get_header_image(); } elseif (!is_front_page() && get_theme_mod('family_header_home')) { echo ''; } else { // get title $id = get_option('page_for_posts'); if ('posts' == get_option('show_on_front') && (is_day() || is_month() || is_year() || is_tag() || is_category() || is_singular('post') || is_home())) { family_get_header_image(); } elseif (is_home() || is_singular('post')) { if (has_post_thumbnail($id)) { echo get_the_post_thumbnail($id, 'full'); } else { family_get_header_image(); } } elseif (has_post_thumbnail() && is_singular('page')) { the_post_thumbnail(); } else { family_get_header_image(); } } ?> </div><!-- .wrap --> </div><!-- .banner --> <?php }
/** * Add breadcrumbs functionality to your WordPress theme * * Once you have included the function in your functions.php file * you can then place the following anywhere in your theme templates * if(function_exists('bootstrap_breadcrumbs')) bootstrap_breadcrumbs(); * * credit to: c.bavota - http://bavotasan.com (thanks for the code start) */ function bootstrap_breadcrumbs() { echo '<ol class="breadcrumb">'; echo '<li><a href="' . home_url('/') . '">Home</a></li>'; // are we at "blog home"? if (is_home()) { echo '<li><a href="#">Blogs</a></li>'; } // where else do we want breadcrumbs if (!is_page_template('pt-home.php') && !is_home()) { // check if we're in a commerce plugin if (function_exists('is_woocommerce') && is_woocommerce()) { echo '<li><a href="/publications/order/">Shop</a></li>'; $product_cats = wp_get_post_terms(get_the_ID(), 'product_cat'); echo '<li><a href="/publications/order/' . str_replace(" ", "-", $product_cats[0]->name) . '">' . $product_cats[0]->name . '</a></li>'; } // breadcrumb wordpress structures if (is_category() || is_single() || is_single('aof')) { if (get_the_category()) { $category = get_the_category(); echo '<li><a href="/blog/category/' . str_replace(" ", "-", $category[0]->cat_name) . '">' . $category[0]->cat_name . '</a></li>'; } if (is_single()) { echo '<li class="active">'; the_title(); echo '</li>'; } } elseif (is_page()) { echo '<li class="active">'; the_title(); echo '</li>'; } } echo '</ol>'; }