Skip to content

Instantly share code, notes, and snippets.

@mdjwel
Created January 19, 2019 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdjwel/8f3b029cae522c722d634e70691dafd8 to your computer and use it in GitHub Desktop.
Save mdjwel/8f3b029cae522c722d634e70691dafd8 to your computer and use it in GitHub Desktop.
Display theme banner title based on what the page is
<?php
// Banner Title
function saasland_banner_title() {
$opt = get_option('saasland_opt');
if(is_home()) {
$blog_title = !empty($opt['blog_title']) ? $opt['blog_title'] : esc_html__('Blog', 'appland');
echo esc_html($blog_title);
}
elseif(is_page() || is_single()) {
the_title();
}
elseif(is_archive()) {
the_archive_title();
}
elseif(is_category()) {
single_cat_title();
}
elseif (class_exists('WooCommerce')) {
if (is_shop()) {
echo !empty($opt['shop_title']) ? esc_html($opt['shop_title']) : esc_html__('Shop', 'saasland');
}
}
else {
the_title();
}
}
function saasland_banner_subtitle() {
if(is_home()) {
$blog_subtitle = !empty($opt['blog_subtitle']) ? $opt['blog_subtitle'] : get_bloginfo('description');
echo esc_html($blog_subtitle);
}
elseif(is_page() || is_single()) {
echo nl2br(get_the_excerpt());
}
elseif (class_exists('WooCommerce')) {
if (is_shop()) {
echo !empty($opt['shop_subtitle']) ? esc_html($opt['shop_subtitle']) : '';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment