Add different logo to wordpress pages - php

I have a theme i am customizing on wordpress(Increate themes), the thing is the owner wants a page that talks something different and it will also have a different logo, my question is how can i insert a different logo to the page.
this is my theme header.php logo part
<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?> class="no-js">
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<?php global $ht_options; ?>
<!-- favicon -->
<?php if($ht_options['custom_favicon']) { echo ht_favicon($ht_options['custom_favicon']);} ?>
<?php if($ht_options['apple_ipad_logo']): ?>
<!-- For iPad -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php echo $ht_options['apple_ipad_logo']; ?>">
<?php endif; ?>
<?php if($ht_options['apple_logo']): ?>
<!-- For iPhone -->
<link rel="apple-touch-icon-precomposed" href="<?php echo $ht_options['apple_logo']; ?>">
<?php endif; ?>
<!-- responsive -->
<?php if( $ht_options['responsive_layout'] =='responsive' ) {?>
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
<?php } ?>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=EmulateIE8; IE=EDGE" />
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- RSS feed -->
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php if ( $ht_options['rss_id'] <> "" ) { echo $ht_options['rss_id']; } else { echo get_bloginfo_rss('rss2_url'); } ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php echo $ht_options['before_head']; ?>
<?php wp_head(); ?>
</head>
<?php
$dark_layout = '';
if( $ht_options['dark_skin'] ){
$dark_layout = 'dark-layout';
}
?>
<body <?php body_class($dark_layout); ?>>
<div id="frame_">
<div id="layout" class="<?php echo $ht_options['layout_type']; ?> ">
<header id="header">
<?php if(!$ht_options['disable_top_header']) {?>
<div class="head_up">
<div class="row clearfix">
<div class="l_ht">
<?php echo $ht_options['top_header_info'];?>
</div><!-- end text left -->
<div class="r_ht">
<?php
if( is_woocommerce_activated() ):
global $woocommerce;
$total_amount = $woocommerce->cart->get_cart_total();
$cart_item_counts = $woocommerce->cart->cart_contents_count;
$cart_url = $woocommerce->cart->get_cart_url();
$checkout_url = $woocommerce->cart->get_checkout_url();
?>
<div class="shopping_bag">
<div class="header_bag">
<i class="icon_bag_alt"></i><span> <?php echo $cart_item_counts;?> <?php _e("item(s)", "highthemes");?> / <?php echo $total_amount;?></span>
</div><!-- .header_bag -->
<div class="view_cart_mini">
<div class="view_cart">
<?php if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {?>
<ul class="cart_list">
<?php
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
if ( $_product->exists() && $values['quantity'] > 0 ) {
?>
<li class="clearfix">
<?php
$thumbnail = apply_filters( 'woocommerce_in_cart_product_thumbnail', $_product->get_image(), $values, $cart_item_key );
printf('%s', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), $thumbnail );
?>
<div class="cart_list_product_title">
<?php
if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) )
echo apply_filters( 'woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key );
else
printf('%s', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), apply_filters('woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key ) );
// Meta data
echo $woocommerce->cart->get_item_data( $values );
// Backorder notification
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $values['quantity'] ) )
echo '<p class="backorder_notification">' . __( 'Available on backorder', 'highthemes' ) . '</p>';
if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1', $cart_item_key );
} else {
$product_quantity = esc_attr( $values['quantity'] );
}
?>
<div class="cart_list_product_quantity"><?php _e("Quantity", "highthemes");?>: <?php echo $product_quantity;?> / <?php
echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('[x]', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'highthemes' ) ), $cart_item_key );
?>
</div><!-- .cart_list_prodcut_quantity -->
</div>
</li>
<?php
}
}
?>
</ul><!-- .cart_list-->
<span class="total_checkout fll"><?php _e("Cart subtotal", "highthemes");?></span>
<span class="amount_total flr">
<?php
echo $total_amount;
?>
</span>
<div class="tac" style="clear:both">
<span><?php _e("View Cart", "highthemes");?></span>
<span><i class="icon_cart_alt mi"></i><?php _e("Checkout", "highthemes");?></span>
</div>
<?php } else { // end check if cart ?>
<p>
<?php _e("Your cart is empty!", "highthemes");?>
</p>
<?php }?>
</div>
</div>
</div>
<?php endif // if woocommerc is activated;?>
<?php
if( function_exists('icl_get_languages') ){
$langs = icl_get_languages('skip_missing=1');
if($langs) {
$current_lang = '';
foreach ($langs as $key => $lang) {
if($lang['active']){
$current_lang = $lang;
unset($langs[$key]);
}
}
?>
<div class="languages">
<?php if ( $current_lang ) {
echo '<a title="'.$lang['native_name'].'" href="'. $current_lang['url'] .'"><span>'. strtoupper($current_lang['language_code']) .'</span></a>';
}?>
<div class="other_languages">
<?php
foreach ($langs as $key => $lang) {
echo '<a title="'.$lang['native_name'].'" href="'. $lang['url'] .'"><span>'. strtoupper($lang['language_code']) .'</span></a>';
}
?>
</div><!-- end other -->
</div><!-- end languages -->
<?php } }// end wpml ?>
<div class="social social_head">
<?php echo ht_social_icons_list();?>
</div><!-- end social -->
</div><!-- end social and bag -->
</div><!-- row -->
</div><!-- head -->
<?php }?>
<?php
$sticky_header = '';
if( $ht_options['sticky_header'] ) {
$sticky_header = 'my_sticky';
}
?>
<div class="headdown <?php echo $sticky_header;?>">
<div class="row clearfix">
<div class="logo">
<a title="<?php bloginfo("description");?>" href="<?php echo home_url();?>">
<?php if ($ht_options['logo_url']) { ?>
<img src="<?php echo $ht_options['logo_url'];?>" alt="<?php bloginfo('description'); ?>"/>
<?php } else { ?>
<img src="<?php echo get_template_directory_uri();?>/images/logo.png" alt="Logo"/>
<?php }?>
</a>
</div>
<?php if(!$ht_options['disable_top_search']) {?>
<div class="search">
<div class="search_icon"><i class="icon_search icon_close"></i></div>
<div class="s_form">
<form action="<?php echo site_url(); ?>/" id="search" method="get">
<input id="inputhead" name="s" type="text" onfocus="if (this.value=='<?php _e("Start Searching...", "highthemes");?>') this.value = '';" onblur="if (this.value=='') this.value = '<?php _e("Start Searching...", "highthemes");?>';" value="<?php _e("Start Searching...", "highthemes");?>" placeholder="<?php _e("Start Searching...", "highthemes");?>">
<button type="submit"><i class="icon_search"></i></button>
</form><!-- end form -->
</div>
</div>
<?php }?>
<?php wp_nav_menu( array('menu_class' => 'sf-menu', 'menu_id' => 'menu', 'menu' => 'default', 'container' => 'nav','theme_location' => 'nav', 'container_id' => 'nav' ) ); ?>
<!-- end nav -->
</div><!-- row -->
</div><!-- headdown -->
</header><!-- end header -->
<?php
$ht_header_type = '';
if($post){
$ht_header_type = ht_get_header_type(get_the_ID());
}
?>
<?php if ( is_page_template('tpl-under-construction.php') ) {?>
<?php } elseif( $ht_header_type =='rev-slider' ) { ?>
<div class="sliderr" id="main-slideshow">
<?php
if(function_exists('putRevSlider')) {
putRevSlider(get_post_meta(get_the_ID(), '_ht_rev_slider', true));
}
?>
</div>
<?php
$overlay_caption_title = get_post_meta( get_the_ID(), '_ht_overlay_caption_title', true );
$overlay_button1_title = get_post_meta( get_the_ID(), '_ht_overlay_button1_title', true );
$overlay_button1_link = get_post_meta( get_the_ID(), '_ht_overlay_button1_link', true );
$overlay_button1_icon = get_post_meta( get_the_ID(), '_ht_overlay_button1_icon', true );
$overlay_button2_title = get_post_meta( get_the_ID(), '_ht_overlay_button2_title', true );
$overlay_button2_link = get_post_meta( get_the_ID(), '_ht_overlay_button2_link', true );
$overlay_button2_icon = get_post_meta( get_the_ID(), '_ht_overlay_button2_icon', true );
if( !empty($overlay_button1_title) || !empty($overlay_button2_title) || !empty($overlay_caption_title) ) {?>
<div class="intro_p tac">
<div class="row inner clearfix">
<?php if( !empty($overlay_caption_title) ) {?>
<h2><?php echo $overlay_caption_title;?></h2>
<?php }?>
<?php if( !empty($overlay_button1_title) ) {?>
<a href="<?php echo $overlay_button1_link;?>" class="tbutton large">
<?php if( !empty($overlay_button1_icon) ) {?><i class="<?php echo $overlay_button1_icon;?>"></i><?php }?>
<span><?php echo $overlay_button1_title;?></span></a>
<?php } ?>
<?php if( !empty($overlay_button2_title) ) {?>
<a href="<?php echo $overlay_button2_link;?>" class="tbutton large m_left">
<?php if( !empty($overlay_button2_icon) ) {?><i class="<?php echo $overlay_button2_icon;?>"></i><?php }?>
<span><?php echo $overlay_button2_title;?></span></a>
<?php } ?>
</div><!-- End row -->
</div><!-- End intro p -->
<?php }?>
<?php } else if ( $ht_header_type =='title' ) {
$header_bg_repeat = $header_bg_position = $header_bg_cover = '';
if(is_page() || is_single() ) {
$header_centered = get_post_meta( get_the_ID(), '_ht_header_centered', true );
}
$header_background = get_post_meta( get_the_ID(), '_ht_header_background', true );
if( empty($header_background) || $header_background =='default' ) {
$header_bg = 'background-image:url('.get_template_directory_uri().'/images/assets/breadcrumb1.jpg); background-repeat: no-repeat;-webkit-background-size: cover;-moz-background-size: cover;-o-background-size:cover; background-size: cover;' ;
} elseif ( $header_background == 'custom' ) {
$header_bg = get_post_meta( get_the_ID(), '_ht_header_bg', true );
$header_bg_repeat = get_post_meta( get_the_ID(), '_ht_header_bg_repeat', true );
$header_bg_position = get_post_meta( get_the_ID(), '_ht_header_bg_position', true );
$header_bg_cover = get_post_meta( get_the_ID(), '_ht_header_bg_cover', true );
$header_bg = ( !empty($header_bg) ) ? wp_get_attachment_image_src( $header_bg, 'full') : '';
$header_bg = ( !empty($header_bg) ) ? 'background-image:url(' . $header_bg[0] . ');' : '';
$header_bg_repeat = ( !empty($header_bg) ) ? 'background-repeat:' . $header_bg_repeat . ';' : '';
$header_bg_position = ( !empty($header_bg) ) ? 'background-position:' . $header_bg_position . ';' : '';
$header_bg_cover = ( !empty($header_bg) && !empty($header_bg_cover) ) ? 'background-repeat:no-repeat;-webkit-background-size: cover;-moz-background-size: cover;-o-background-size:cover; background-size: cover;' : '';
} else {
$header_bg = 'background-image:url('.get_template_directory_uri().'/images/assets/'.$header_background.'); background-repeat: no-repeat;-webkit-background-size: cover;-moz-background-size: cover;-o-background-size:cover; background-size: cover;' ;
}
$header_centered = ( !empty($header_centered) ) ? ' centered' : '';
$styles =
$header_bg.
$header_bg_repeat.
$header_bg_position.
$header_bg_cover;
?>
<div class="breadcrumb-place" style="<?php echo $styles;?>">
<div class="row clearfix">
<h3 class="page-title">
<?php
if( is_woocommerce_activated() ) {
if( is_shop() ) {
woocommerce_page_title();
}
}
if ( is_page() || is_single() ) the_title();
else if ( is_category() ) _e("Category : ",'highthemes'). single_cat_title('', true);
else if ( is_tag() ) _e("Tag : ",'highthemes').single_tag_title('', true);
else if ( is_year() ) echo get_the_date( _x( 'Y', 'yearly archives date format', 'highthemes' ) );
else if ( is_month() ) echo get_the_date( _x( 'F Y', 'monthly archives date format', 'highthemes' ) );
else if ( is_day() ) echo get_the_date();
else if ( is_author() ) echo get_the_author();
else if ( is_search() ) printf( __('Search results for','highthemes') . " %s", '"' . get_search_query() . '"' );
else if ( is_tax() ) {
global $wp_query;
$term = $wp_query->get_queried_object();
echo $term->name;
}
?>
</h3>
<?php
if( !is_woocommerce_activated() ) {
if($ht_options['breadcrumb_inner']){ ?>
<?php if (class_exists('simple_breadcrumb')) { $bc = new simple_breadcrumb; } ?>
<?php }
} else {
if(( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) and ($ht_options['breadcrumb_inner'])) {
woocommerce_breadcrumb();
} else if ($ht_options['breadcrumb_inner']) {
?>
<div id="breadcrumb" class="<?php echo $header_centered;?>">
<?php if (class_exists('simple_breadcrumb')) { $bc = new simple_breadcrumb; } ?>
</div>
<?php }
}
?>
</div><!-- row -->
</div><!-- end breadcrumb place -->
<?php } else if ( $ht_header_type =='no-title' ) { } ?>
<?php if(is_404()){?>
<div class="error_page">
<div class="row clearfix">
<div class="CLE">
<i class="icon_dislike errori"></i>
<h2 class="tac mtt"> <?php _e("PAGE NOT FOUND", "highthemes");?> <small> <?php _e("The page you are looking for might have been removed.","highthemes");?> </small></h2>
<span><i class="icons-arrow-left mi"></i> <?php _e("Back To Homepage", "highthemes");?></span>
</div>
</div><!-- row -->
</div><!-- end 404 place -->
<?php }?>
<?php
if( is_single() && get_post_type() == 'portfolio' ) {
$portfolio_single_layout = get_post_meta( get_the_ID(), '_ht_portfolio_single_layout', true);
if($portfolio_single_layout == 'image_left' || $portfolio_single_layout == 'image_right'){
?>
<div class="hidden-x page-content no-sidebar">
<?php } else { ?>
<div class="hidden-x page-content <?php echo ht_sidebar_layout();?>">
<?php }?>
<?php } else {?>
<div class="hidden-x page-content <?php echo ht_sidebar_layout();?> ">
<?php }?>

You could do something on header.php
if ($_SERVER["SCRIPT_NAME"] != '/the-page-you-want-a-custom-logo/index.php') {
<?php if ($ht_options['logo_url']) { ?>
<img src="<?php echo $ht_options['logo_url'];?>" alt="<?php bloginfo('description'); ?>"/>
<?php } else { ?>
<img src="<?php echo get_template_directory_uri();?>/images/logo.png" alt="Logo"/>
<?php }?>
} else {
<img src="/images/yourcustomlogo.jpg" alt="Logo"/>
}

Related

Mega Menu without Plugin (WordPress) (code is ready but doesn't work)

I'm asking for help.
This is my header structure:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div id="wrapper" class="hfeed">
<header id="header" role="banner">
<div id="branding">
<div id="site-title">
<?php if ( is_front_page() || is_home() || is_front_page() && is_home() ) { echo '<h1>'; } ?>
<?php echo esc_html( get_bloginfo( 'name' ) ); ?>
<?php if ( is_front_page() || is_home() || is_front_page() && is_home() ) { echo '</h1>'; } ?>
</div>
<div id="site-description"><?php bloginfo( 'description' ); ?></div>
</div>
<nav id="menu" role="navigation">
<button type="button" class="menu-toggle"><span class="menu-icon">☰</span><span class="menu-text screen-reader-text"><?php esc_html_e( ' Menu', 'generic' ); ?></span></button>
<?php
$menu_name = 'main-menu';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
?>
<ul class="nav">
<?php
$count = 0;
$submenu = true;
foreach( $menuitems as $item ):
// set up title and url
$title = $item->title;
$link = $item->url;
// item does not have a parent so menu_item_parent equals 0 (false)
if ( !$item->menu_item_parent ):
if ( is_active_sidebar( 'mega-menu-widget-area-' . $item->ID ) ) {
echo "<div id=\"mega-menu-{$item->ID}\" class=\"mega-menu\">";
dynamic_sidebar( 'mega-menu-widget-area-' . $item->ID );
echo "</div>";
}
// save this id for later comparison with sub-menu items
$parent_id = $item->ID;
?>
<li>
<a href="<?php echo $link; ?>">
<span><?php echo $title; ?></span>
</a>
<?php endif; ?>
<?php if ( $parent_id == $item->menu_item_parent ):
?>
<?php if ( !$submenu ): $submenu = true;
?>
<div class="mega-menu sub-menu-columns">
<div class="mega-bg">
<div class="mega-mrg">
<div class="maga-half">
<ul>
<?php endif; ?>
<li><?php echo $title; ?></li>
<?php if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id && $submenu ): ?>
</ul>
</div>
</div>
</div>
</div>
<?php $submenu = false; endif; ?>
<?php endif; ?>
<?php if (#$menuitems[ $count + 1 ]->menu_item_parent != $parent_id ): ?>
</li>
<?php $submenu = false; endif; ?>
<?php $count++; endforeach; ?>
</ul>
</nav>
</header>
<div id="container">
I've registered a custom sidebar in the functions.php
function wpmm_init() {
$location = 'main-menu';
$css_class = 'has-mega-menu';
$locations = get_nav_menu_locations();
if ( isset( $locations[ $location ] ) ) {
$menu = get_term( $locations[ $location ], 'nav_menu' );
if ( $items = wp_get_nav_menu_items( $menu->name ) ) {
foreach ( $items as $item ) {
if ( in_array( $css_class, $item->classes ) ) {
register_sidebar( array(
'id' => 'mega-menu-widget-area-' . $item->ID,
'name' => $item->title . ' - Mega Menu',
) );
}
}
}
}
}
add_action( 'widgets_init', 'wpmm_init' );
Now - if menu item has class "has-mega-menu" the widget itself is being created only for the particular menu item. I can put there image, html, custom links etc.
if menu item has class " has-mega-menu " this widget gets unique id and there I can put my image and some description.
Unfortunately it doesn't work. The container containing image and the rest of links for example, is outputted outside of the parent with ul
I want that particular, unique widget to be outputted within the ul class (parent) so it will work like mega menu. Can someone help me? Please. I'm trying to fix this code (I'm just beginner) but this is literally third day and I can't find a solution.
Not quite sure from your code example, but this should fix your problems with missplacement
register_sidebar( array(
'id' => 'mega-menu-widget-area-' . $item->ID,
'name' => $item->title . ' - Mega Menu',
'before_widget' => '',
'after_widget' => '',
) );

keep h1 title on homepage

I have h1 title i put in my home page, but i want to keep it only in my home page. now it shows in
every single page in the site
im using wordpress and i put it in the header php
<?php
get_template_part( 'framework/parts/breaking-news' ); // Get Breaking News template
tie_banner('banner_below_header' , '<div class="e3lan e3lan-below_header">' , '</div>' );
?>
**<h1 style="padding-left:25px; padding-bottom:5px">stiri sportive</h1>**
this is all the header.php code
<!DOCTYPE html>
<html <?php language_attributes(); ?> prefix="og: http://ogp.me/ns#">
<head>
<meta name="google-site-verification" content="PUSf9MdDStKBNkOow1SskiNxuNcQOOzCf7ruKMyjCyE" />
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_head(); ?>
</head>
<?php global $is_IE ?>
<body id="top" <?php body_class(); ?>>
<div class="wrapper-outer">
<?php if( tie_get_option('banner_bg_url') && tie_get_option('banner_bg') ): ?>
<?php else: ?>
<div class="background-cover"></div>
<?php endif; ?>
<?php if( tie_get_option( 'mobile_menu_active' ) ): ?>
<aside id="slide-out">
<?php if( tie_get_option( 'mobile_menu_search' ) ): ?>
<div class="search-mobile">
<form method="get" id="searchform-mobile" action="<?php echo home_url(); ?>/">
<button class="search-button" type="submit" value="<?php if( !$is_IE ) _eti( 'Search' ) ?>"><i class="fa fa-search"></i></button>
<input type="text" id="s-mobile" name="s" title="<?php _eti( 'Search' ) ?>" value="<?php _eti( 'Search' ) ?>" onfocus="if (this.value == '<?php _eti( 'Search' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _eti( 'Search' ) ?>';}" />
</form>
</div><!-- .search-mobile /-->
<?php endif; ?>
<?php if( tie_get_option('mobile_menu_social') ):
tie_get_social( true , false , 'ttip-none' ); ?>
<?php endif; ?>
<div id="mobile-menu" <?php if( !tie_get_option('mobile_menu_hide_icons') ) echo' class="mobile-hide-icons"';?>></div>
</aside><!-- #slide-out /-->
<?php endif; ?>
<?php $full_width =''; if( tie_get_option( 'full_logo' )) $full_width = ' full-logo';
$center_logo =''; if( tie_get_option( 'center_logo' )) $center_logo = ' center-logo';
$theme_layout = 'boxed';
if( tie_get_option( 'theme_layout' ) == 'full' ) $theme_layout = 'wide-layout';
if( tie_get_option( 'theme_layout' ) == 'boxed-all' ) $theme_layout = 'boxed-all';
?>
<div id="wrapper" class="<?php echo $theme_layout ?>">
<div class="inner-wrapper">
<header id="theme-header" class="theme-header<?php echo $full_width.$center_logo ?>">
<?php if( tie_get_option( 'top_menu' ) ): ?>
<div id="top-nav" class="top-nav">
<div class="container">
<?php if(tie_get_option( 'top_date' )):
if( tie_get_option('todaydate_format') ) $date_format = tie_get_option('todaydate_format');
else $date_format = 'l , j F Y';
?>
<span class="today-date"><?php echo date_i18n( $date_format , current_time( 'timestamp' ) ); ?></span><?php endif; ?>
<?php wp_nav_menu( array( 'container_class' => 'top-menu', 'theme_location' => 'top-menu' ) ); ?>
<?php if( tie_get_option( 'top_search' ) ): ?>
<div class="search-block">
<form method="get" id="searchform-header" action="<?php echo home_url(); ?>/">
<button class="search-button" type="submit" value="<?php if( !$is_IE ) _eti( 'Search' ) ?>"><i class="fa fa-search"></i></button>
<input class="search-live" type="text" id="s-header" name="s" title="<?php _eti( 'Search' ) ?>" value="<?php _eti( 'Search' ) ?>" onfocus="if (this.value == '<?php _eti( 'Search' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _eti( 'Search' ) ?>';}" />
</form>
</div><!-- .search-block /-->
<?php endif;
if( tie_get_option('top_social') ):
tie_get_social( true , false , 'ttip-none' ); ?>
<?php endif; ?>
<?php tie_language_selector_flags(); ?>
</div><!-- .container /-->
</div><!-- .top-menu /-->
<?php endif; ?>
<div class="header-content">
<?php if( tie_get_option( 'mobile_menu_active' ) ): ?>
<a id="slide-out-open" class="slide-out-open" href="#"><span></span></a>
<?php endif; ?>
<?php
if( is_category() || is_single() ){
if( is_category() ) $category_id = get_query_var('cat') ;
if( is_single() ){
$categories = get_the_category( $post->ID );
if( !empty( $categories[0]->term_id ) )
$category_id = $categories[0]->term_id ;
}
if( !empty( $category_id ) ){
$tie_cats_options = get_option( 'tie_cats_options' );
if( !empty( $tie_cats_options[ $category_id ] ) )
$cat_options = $tie_cats_options[ $category_id ];
}
}
if( !empty($cat_options['cat_custom_logo']) ){
$logo_margin ='';
if( !empty( $cat_options['logo_margin'] ) || !empty( $cat_options['logo_margin_bottom'] ) ){
$logo_margin = ' style="';
if( !empty( $cat_options['logo_margin'] ) )
$logo_margin .= ' margin-top:'.$cat_options['logo_margin'].'px;';
if( !empty( $cat_options['logo_margin_bottom'] ) )
$logo_margin .= ' margin-bottom:'.$cat_options['logo_margin_bottom'].'px;';
$logo_margin .= '"';
}
?>
<div class="logo"<?php echo $logo_margin ?>>
<h2>
<?php if( $cat_options['logo_setting'] == 'title' ): ?>
<?php echo single_cat_title( '', false ) ?>
<?php else : ?>
<?php if( !empty($cat_options['logo']) ) $logo = $cat_options['logo'];
elseif( tie_get_option( 'logo' ) ) $logo = tie_get_option( 'logo' );
else $logo = get_stylesheet_directory_uri().'/images/logo.png';
?>
<a title="<?php bloginfo('name'); ?>" href="<?php echo home_url(); ?>/">
<img src="<?php echo $logo ; ?>" alt="<?php echo single_cat_title( '', false ) ?>" <?php if( $cat_options['logo_retina_width'] && $cat_options['logo_retina_height'] ) echo 'width="'.$cat_options['logo_retina_width'] .'" height="'.$cat_options['logo_retina_height'].'"'; ?> /><strong><?php echo single_cat_title( '', false ) ?></strong>
</a>
<?php endif; ?>
</h2>
</div><!-- .logo /-->
<?php if( $cat_options['logo_retina'] && $cat_options['logo_retina_width'] && $cat_options['logo_retina_height']): ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
var retina = window.devicePixelRatio > 1 ? true : false;
if(retina) {
jQuery('#theme-header .logo img').attr('src', '<?php echo $cat_options['logo_retina']; ?>');
jQuery('#theme-header .logo img').attr('width', '<?php echo $cat_options['logo_retina_width']; ?>');
jQuery('#theme-header .logo img').attr('height', '<?php echo $cat_options['logo_retina_height']; ?>');
}
});
</script>
<?php endif; ?>
<?php
}else{
$logo_margin ='';
if( tie_get_option( 'logo_margin' ) || tie_get_option( 'logo_margin_bottom' ) ){
$logo_margin = ' style="';
if( tie_get_option( 'logo_margin' ) )
$logo_margin .= ' margin-top:'.tie_get_option( 'logo_margin' ).'px;';
if( tie_get_option( 'logo_margin_bottom' ) )
$logo_margin .= ' margin-bottom:'.tie_get_option( 'logo_margin_bottom' ).'px;';
$logo_margin .= '"';
}
?>
<div class="logo"<?php echo $logo_margin ?>>
<?php if( is_home() || is_front_page() ) echo '<img>'; else echo '<img>'; ?>
<?php if( tie_get_option('logo_setting') == 'title' ): ?>
<?php bloginfo('name'); ?>
<span><?php bloginfo( 'description' ); ?></span>
<?php else : ?>
<?php if( tie_get_option( 'logo' ) ) $logo = tie_get_option( 'logo' );
else $logo = get_stylesheet_directory_uri().'/images/logo.png';
?>
<a title="<?php bloginfo('name'); ?>" href="<?php echo home_url(); ?>/">
<img src="<?php echo $logo ; ?>" alt="<?php bloginfo('name'); ?>" <?php if( tie_get_option('logo_retina_width') && tie_get_option('logo_retina_height') ) echo 'width="'.tie_get_option('logo_retina_width') .'" height="'.tie_get_option('logo_retina_height').'"'; ?> /><strong><?php bloginfo('name'); ?> <?php bloginfo( 'description' ); ?></strong>
</a>
<?php endif; ?>
<?php if( is_home() || is_front_page() ) echo '</img>'; else echo '</img>'; ?>
</div><!-- .logo /-->
<?php if( tie_get_option( 'logo_retina' ) && tie_get_option( 'logo_retina_width' ) && tie_get_option( 'logo_retina_height' )): ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
var retina = window.devicePixelRatio > 1 ? true : false;
if(retina) {
jQuery('#theme-header .logo img').attr('src', '<?php echo tie_get_option( 'logo_retina' ); ?>');
jQuery('#theme-header .logo img').attr('width', '<?php echo tie_get_option( 'logo_retina_width' ); ?>');
jQuery('#theme-header .logo img').attr('height', '<?php echo tie_get_option( 'logo_retina_height' ); ?>');
}
});
</script>
<?php endif; ?>
<?php } ?>
<?php tie_banner('banner_top' , '<div class="e3lan e3lan-top">' , '</div>' ); ?>
<div class="clear"></div>
</div>
<?php $stick = ''; ?>
<?php if( tie_get_option( 'stick_nav' ) ) $stick = ' class="fixed-enabled"' ?>
<?php if( tie_get_option( 'main_nav' ) ): ?>
<?php
//UberMenu Support
$navID = 'main-nav';
if ( class_exists( 'UberMenu' ) ){
$uberMenus = get_option( 'wp-mega-menu-nav-locations' );
if( !empty($uberMenus) && is_array($uberMenus) && in_array("primary", $uberMenus)) $navID = 'main-nav-uber';
}?>
<nav id="<?php echo $navID; ?>"<?php echo $stick; ?>>
<div class="container">
<?php if( tie_get_option( 'nav_logo' ) ): ?>
<a class="main-nav-logo" title="<?php bloginfo('name'); ?>" href="<?php echo home_url(); ?>/">
<img src="<?php echo tie_get_option( 'nav_logo' ) ?>" width="195" height="54" alt="<?php bloginfo('name'); ?>">
</a>
<?php endif ?>
<?php wp_nav_menu( array( 'container_class' => 'main-menu', 'theme_location' => 'primary', 'walker' => new tie_mega_menu_walker(), 'fallback_cb'=> false) ); ?>
<?php if(tie_get_option( 'random_article' )): ?>
<i class="fa fa-random"></i>
<?php endif ?>
<?php if( tie_get_option( 'shopping_cart' ) && function_exists( 'is_woocommerce' ) ):
global $woocommerce; ?>
<a class="tie-cart ttip" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _eti( 'View your shopping cart' ); ?>"><span class="shooping-count-outer"><?php if( isset( $woocommerce->cart->cart_contents_count ) && ( $woocommerce->cart->cart_contents_count != 0 ) ){ ?><span class="shooping-count"><?php echo $woocommerce->cart->cart_contents_count ?></span><?php } ?><i class="fa fa-shopping-cart"></i></span></a>
<?php endif ?>
</div>
</nav><!-- .main-nav /-->
<?php endif; ?>
</header><!-- #header /-->
<?php get_template_part( 'framework/parts/breaking-news' ); // Get Breaking News template ?>
<?php tie_banner('banner_below_header' , '<div class="e3lan e3lan-below_header">' , '</div>' ); ?>
<h1 style="padding-left:25px; padding-bottom:5px">stiri sportive</h1>
<?php
$sidebar = '';
if( tie_get_option( 'sidebar_pos' ) == 'left' ) $sidebar = ' sidebar-left';
if( is_singular() || ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) ){
$current_ID = $post->ID;
if( function_exists( 'is_woocommerce' ) && is_woocommerce() ) $current_ID = woocommerce_get_page_id('shop');
$get_meta = get_post_custom( $current_ID );
if( !empty($get_meta["tie_sidebar_pos"][0]) ){
$sidebar_pos = $get_meta["tie_sidebar_pos"][0];
if( $sidebar_pos == 'left' ) $sidebar = ' sidebar-left';
elseif( $sidebar_pos == 'full' ) $sidebar = ' full-width';
elseif( $sidebar_pos == 'right' ) $sidebar = ' sidebar-right';
}
}
if( ( function_exists('is_bbpress') && is_bbpress() && tie_get_option( 'bbpress_full' )) || is_404() ) $sidebar = ' full-width';
?>
<div id="main-content" class="container<?php echo $sidebar ; ?>">
what to add to the code so the title will show only in the homepage
You could wrap the h1 in an if statement using is_home() and is_frontpage().
<?php if( is_home() || is_front_page() ) : ?>
<h1 style="padding-left:25px; padding-bottom:5px">stiri sportive</h1>
<?php endif; ?>
is_home() returns true or false depending on whether the page being shown is the 'Front Page' or not.
You should consider restructuring things though, so that this forms part of the home page template, rather than being run on every page of your website.
is_home() docs: https://developer.wordpress.org/reference/functions/is_home/
You can wrap your <h1> tag with a conditional statement checking whether the page is the homepage or not:
<?php if ( is_home() || is_front_page() ) { ?>
<h1 style="padding-left:25px; padding-bottom:5px">stiri sportive</h1>
<?php } ?>
This way, the H1 tag will only show on the website's homepage.

add badge to thumbnail image

What I want to do on the front page where I have recent posts, is to add a small upper corner badge or ribbon that says "NEW" to the thumbnails of posts that were published on today's date. Below is my index.php which controls the front page layout:
<?php
/**
* The main template file.
*
* Used to display the homepage when home.php doesn't exist.
*/
?>
<?php
// Get options
$mts_options = get_option(MTS_THEME_NAME);
// Featured Section 1 settings ( slider is here) --------------------------------
$slider_enabled = ( $mts_options['mts_featured_slider'] === '1' ) ? true : false;
if ( empty($mts_options['mts_featured_slider_cat']) || !is_array($mts_options['mts_featured_slider_cat']) ) {
$mts_options['mts_featured_slider_cat'] = array('0');
}
$slider_cat = implode(",", $mts_options['mts_featured_slider_cat']);
// Featured Section settings --------------------------------------------------
$f2_title = $mts_options['mts_featured_section_2_title'];
if ( empty($mts_options['mts_featured_section_2_cat']) || !is_array($mts_options['mts_featured_section_2_cat']) ) {
$mts_options['mts_featured_section_2_cat'] = array('0');
}
$f2_cat= implode(",", $mts_options['mts_featured_section_2_cat']);
// Featured Section 3 settings --------------------------------------------------
get_header(); ?>
<div id="page">
<div class="article">
<?php if ( $slider_enabled && is_home() && !is_paged() ) { ?>
<section id="featured-section-1" class="featured-section featured-section-1-1 clearfix">
<div class="slider-container">
<div class="primary-slider-container clearfix loading">
<div id="slider" class="primary-slider">
<?php
$slider_full = 'best-featuredfull';
if ( empty( $mts_options['mts_custom_slider'] ) ) {
$my_query = new WP_Query('cat='.$slider_cat.'&posts_per_page='.$mts_options['mts_featured_slider_num']);
while ( $my_query->have_posts() ) : $my_query->the_post();
?>
<div>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail($slider_full,array('title' => '')); ?>
<div class="slider-caption">
<?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']) && $mts_options['mts_home_headline_meta_info']['enabled']){ ?>
<div class="sliderdate">
<?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']['date']) == '1') { ?>
<span class="thetime updated"><?php the_time( get_option( 'date_format' ) ); ?></span>
<?php } ?>
</div>
<?php } ?>
<h2 class="slide-title"><?php the_title(); ?></h2>
</div>
<div class="post-day"><?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'review-total-only'); ?></div>
</a>
</div>
<?php endwhile; wp_reset_postdata();
} else { ?>
<?php foreach( $mts_options['mts_custom_slider'] as $slide ) : ?>
<div>
<a href="<?php echo esc_url( $slide['mts_custom_slider_link'] ); ?>">
<?php echo wp_get_attachment_image( $slide['mts_custom_slider_image'], $slider_full, false, array('title' => '') ); ?>
<div class="slider-caption">
<div class="sliderdate"><?php echo esc_html( $slide['mts_custom_slider_title'] ); ?></div>
<h2 class="slide-title"><?php echo esc_html( $slide['mts_custom_slider_text'] ); ?></h2>
</div>
</a>
</div>
<?php endforeach; ?>
<?php } ?>
</div>
</div>
</div><!-- slider-container -->
</section>
<?php } ?>
<?php if( $mts_options['mts_featured_section_2'] === '1' && is_home() && !is_paged() ) {// featured section 2 ?>
<section id="featured-section-3" class="featured-section clearfix">
<?php if (!empty($f2_title)) { ?><h4 class="featured-section-title"><?php echo $f2_title;?></h4><?php } ?>
<?php
$f2_query = new WP_Query('cat='.$f2_cat.'&posts_per_page=4');
$f2_count = 1; if ($f2_query->have_posts()) : while ($f2_query->have_posts()) : $f2_query->the_post();
$f2_loop_params = best_mixed_layout_params( 1, 2, $f2_count );// see functions.php
$f2_clear_class = $f2_loop_params['clear_class'];
$f2_type_class = $f2_loop_params['box_class'];
$f2_loop_thumb = $f2_loop_params['thumb'];
$f2_show_excerpt = $f2_loop_params['show_excerpt'];
$f2_show_author = $f2_loop_params['show_author'];
$begin_f2_extra_wrappers = $f2_loop_params['open_wrappers'];
$end_f2_extra_wrappers = $f2_loop_params['close_wrappers'];
?>
<article class="post-box latestPost mixed <?php echo $f2_type_class;?> <?php echo $f2_clear_class;?>">
<?php echo $begin_f2_extra_wrappers; ?>
<div class="post-img">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="nofollow">
<?php the_post_thumbnail($f2_loop_thumb,array('title' => '')); ?>
</a>
</div>
<div class="post-data">
<div class="post-data-container">
<header>
<h2 class="title post-title"><?php the_title(); ?></h2>
<?php mts_the_postinfo(); ?>
</header>
<?php if ($f2_show_excerpt) : ?>
<div class="post-excerpt">
<?php echo mts_excerpt(40); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php echo $end_f2_extra_wrappers; ?>
</article><!--.post-box-->
<?php $f2_count++; endwhile;
endif; wp_reset_postdata();
?>
</section><!--#featured-section-3-->
<?php } ?>
<div id="content_box">
<?php $latest_posts_used = false;
if ( !empty( $mts_options['mts_featured_categories'] ) ) {
foreach ( $mts_options['mts_featured_categories'] as $section ) {
$category_id = $section['mts_featured_category'];
$featured_category_layout = $section['mts_featured_category_layout'];
$posts_num = $section['mts_featured_category_postsnum'];
if ( $category_id === 'latest' && ! $latest_posts_used ) {
$latest_posts_used = true;
$fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
?>
<section id="latest-posts" class="clearfix<?php echo $fc_section_class ?><?php //echo $fc_section_no_gap ?>">
<h4 class="featured-section-title"><?php _e( "Latest", "best" ); ?></h4>
<?php $j = 1; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php best_the_homepage_article( $featured_category_layout, $j, true );?>
<?php $j++; endwhile; endif; ?>
<!--Start Pagination-->
<?php if (isset($mts_options['mts_pagenavigation_type']) && $mts_options['mts_pagenavigation_type'] == '1' ) { ?>
<?php $additional_loop = 0; mts_pagination($additional_loop['max_num_pages']); ?>
<?php } else { ?>
<div class="pagination pagination-previous-next">
<ul>
<li class="nav-previous"><?php next_posts_link( '<i class="fa fa-chevron-left"></i> '. __( 'Previous', 'best' ) ); ?></li>
<li class="nav-next"><?php previous_posts_link( __( 'Next', 'best' ).' <i class="fa fa-chevron-right"></i>' ); ?></li>
</ul>
</div>
<?php } ?>
<!--End Pagination-->
</section><!--#latest-posts-->
<?php } elseif ( $category_id !== 'latest' && !is_paged() ) {
$fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
?>
<section class="featured-section clearfix<?php echo $fc_section_class ?>">
<h4 class="featured-section-title"><?php echo get_cat_name($category_id); ?></h4>
<?php $cat_query = new WP_Query('cat='.$category_id.'&posts_per_page='.$posts_num); ?>
<?php $j = 1; if ($cat_query->have_posts()) : while ($cat_query->have_posts()) : $cat_query->the_post(); ?>
<?php best_the_homepage_article( $featured_category_layout, $j );?>
<?php $j++; endwhile; endif; wp_reset_postdata();?>
</section>
<?php } ?>
<?php } ?>
<?php } ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
What I have is this: to check the date and display the badge (not including css) but not sure where to input it exactly:
<?php
$days_old = (current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') *3600 ) ) / (60*60*24);
if ($days_old <=1) {
echo <div class="post-badge">NEW</div>;
}
?>
I want to insert it into The Latest Post Section. Any help would be greatly appreciated:)

Remove Parallax background on brooklyn theme

I have an Index.php file that I need to use as a custom page that I would like to have use some of the themes styles and elements Navigation, Footer, Contact Form, ETC.... The default header seems to be calling the body and its very difficult to find the parts of the header. I have been making a considerable amount of changes so the file in drive should be kept updated until I get this resolved.
Currently I have the page/code working thanks to #David and the advice given in this question:
run php application within wordpress
(links and files removed for privacy, and search engine listings removal)
there was a few files missing so I cant test this template itself.
But it is simply a case of replacing php code that calls for a variable with actual output (from view source) to create the template you want.
Go back to using the default index.php (remove the header/footer calls).
Create a new template with the code below and link to it (using the rewrite code from the previous Q you linked above)
There is quite a bit of code in the header.php that calls variables set from the db but hopefully the below code will remove the parallex classes, if not copy the header file and call it header-custom.php. You can replace get_header('custom') to call this header instead. Anywhere you see a php tag inside a html element tag, replace with the actual output you can see in view source.
<?php
/**
* The template for displaying 404 pages (Not Found).
*
* #package unitedthemes
*/
get_header();
?>
<div class="grid-container">
<div id="primary" class="grid-parent grid-100 tablet-grid-100 mobile-grid-100">
<div class="grid-70 prefix-15 mobile-grid-100 tablet-grid-100">
<header class="page-header fullwidth ut-header-light">
<h1 class="page-title"><span><?php _e('RepairStatus'); ?></span></h1>
</header>
<?php require_once get_stylesheet_directory().'/repairstatus/index.php'?>
</div><!-- .page-header -->
</div><!-- .grid-100 mobile-grid-100 tablet-grid-100 -->
</div><!-- .grid-container -->
<?php get_footer(); ?>
header-custom.php contents (call using get_header('custom'); )
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<?php ut_meta_hook(); //action hook, see inc/ut-theme-hooks.php ?>
<?php if ( defined('WPSEO_VERSION') ) : ?>
<!-- Title -->
<title><?php wp_title(); ?></title>
<?php else : ?>
<?php ut_meta_theme_hook(); ?>
<?php endif; ?>
<!-- RSS & Pingbacks -->
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<link rel="profile" href="http://gmpg.org/xfn/11">
<!-- Favicon -->
<?php if( ot_get_option( 'ut_favicon' ) ) : ?>
<?php
/* get icon info */
$favicon = ot_get_option( 'ut_favicon' );
$favicon_info = pathinfo( $favicon );
$type = NULL;
if( isset($favicon_info['extension']) && $favicon_info['extension'] == 'png' ) {
$type = 'type="image/png"';
}
if( isset($favicon_info['extension']) && $favicon_info['extension'] == 'ico' ) {
$type = 'type="image/x-icon"';
}
if( isset($favicon_info['extension']) && $favicon_info['extension'] == 'gif' ) {
$type = 'type="image/gif"';
}
?>
<link rel="shortcut icon" href="<?php echo $favicon; ?>" <?php echo $type; ?> />
<link rel="icon" href="<?php echo $favicon; ?>" <?php echo $type; ?> />
<?php endif; ?>
<!-- Apple Touch Icons -->
<?php if( ot_get_option( 'ut_apple_touch_icon_iphone' ) ) :?>
<link rel="apple-touch-icon" href="<?php echo ot_get_option( 'ut_apple_touch_icon_iphone' ); ?>">
<?php endif; ?>
<?php if( ot_get_option( 'ut_apple_touch_icon_ipad' ) ) : ?>
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo ot_get_option( 'ut_apple_touch_icon_ipad' ); ?>" />
<?php endif; ?>
<?php if( ot_get_option( 'ut_apple_touch_icon_iphone_retina' ) ) : ?>
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo ot_get_option( 'ut_apple_touch_icon_iphone_retina' ); ?>" />
<?php endif; ?>
<?php if( ot_get_option( 'ut_apple_touch_icon_ipad_retina' ) ) :?>
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo ot_get_option( 'ut_apple_touch_icon_ipad_retina' ); ?>" />
<?php endif; ?>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<?php wp_head(); ?>
</head>
<?php
/*
|--------------------------------------------------------------------------
| Needed Settings
|--------------------------------------------------------------------------
*/
$scrollto = ot_get_option('ut_scrollto_effect');
$scrollto = !empty( $scrollto['easing'] ) ? $scrollto['easing'] : 'linear' ;
$scrollspeed = ot_get_option('ut_scrollto_speed' , '650');
$ut_site_border_body_class = ot_get_option( 'ut_site_border', 'hide' ) == 'show' ? 'ut-site-border' : '';
$ut_site_top_header_body_class = ot_get_option( 'ut_top_header', 'hide' ) == 'show' ? 'ut-has-top-header' : '';
$ut_site_border_header_class = ot_get_option( 'ut_site_border', 'hide' ) == 'show' ? 'bordered-navigation' : '';
$ut_top_header_class = ot_get_option( 'ut_top_header' , 'hide' ) == 'show' ? 'bordered-top' : '';
?>
<body id="ut-sitebody" class="error404 " data-scrolleffect="easeInOutExpo" data-scrollspeed="1300">
<a class="ut-offset-anchor" id="top" style="top:0px !important;"></a>
<?php
/*
|--------------------------------------------------------------------------
| Pre Loader Overlay
|--------------------------------------------------------------------------
*/
if( ot_get_option('ut_use_image_loader') == 'on' ) :
if( ut_dynamic_conditional('ut_use_image_loader_on') ) : ?>
<div class="ut-loader-overlay"></div>
<?php endif; ?>
<?php endif; ?>
<?php ut_before_header_hook(); // action hook, see inc/ut-theme-hooks.php ?>
<?php
/*
|--------------------------------------------------------------------------
| Navigation Setting
|--------------------------------------------------------------------------
*/
/* skin */
$ut_navigation_skin = ot_get_option('ut_navigation_skin' , 'ut-header-light');
/* visibility */
$headerstate = NULL;
if( is_home() || is_front_page() || is_singular('portfolio') || get_post_meta( get_the_ID() , 'ut_activate_page_hero' , true ) == 'on' ) {
if( ot_get_option('ut_navigation_state' , 'off') == 'off' ) {
$headerstate = 'ha-header-hide';
}
}
/* width */
$navigation_width = ot_get_option('ut_navigation_width' , 'centered');
$logo_push = ( $navigation_width == 'fullwidth' ) ? 'push-5' : '';
$navigation_pull = ( $navigation_width == 'fullwidth' ) ? 'pull-5' : '';
/* main navigation settings*/
$mainmenu = array('echo' => false,
'container' => 'nav',
'container_id' => 'navigation',
'fallback_cb' => 'ut_default_menu',
'container_class' => 'grid-80 hide-on-tablet hide-on-mobile ' . $navigation_pull ,
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'theme_location' => 'primary',
'walker' => new ut_menu_walker()
);
/* mobile navigation settings */
$mobilemenu = array('echo' => false,
'container' => 'nav',
'container_id' => 'ut-mobile-nav',
'menu_id' => 'ut-mobile-menu',
'menu_class' => 'ut-mobile-menu',
'fallback_cb' => 'ut_default_menu',
'container_class' => 'ut-mobile-menu mobile-grid-100 tablet-grid-100 hide-on-desktop',
'items_wrap' => '<div class="ut-scroll-pane"><ul id="%1$s" class="%2$s">%3$s</ul></div>',
'theme_location' => 'primary',
'walker' => new ut_menu_walker()
);
/* check if current page has an option tp show a hero */
//$ut_activate_page_hero = get_post_meta( get_the_ID() , 'ut_activate_page_hero' , true );
$ut_activate_page_hero= false // --------------------------------------------------------------------------------------------------------------------------------------------------not sure what this returns....
?>
<!-- commented out ----------------------------------------------------->
<?php // get_template_part( 'partials/top', 'header' ); ?>
<!-- header section -->
<header id="header-section" class="ha-header fullwidth ut-header-light ">
<?php if( $navigation_width == 'centered' ) :?>
<div class="grid-container">
<?php endif; ?>
<div class="ha-header-perspective">
<div class="ha-header-front">
<div class="grid-20 tablet-grid-50 mobile-grid-50 <?php echo $logo_push; ?>">
<?php if ( get_theme_mod( 'ut_site_logo' ) ) : ?>
<?php
$sitelogo = !is_front_page() && !is_home() && ( $ut_activate_page_hero == 'off' || empty($ut_activate_page_hero) ) ? get_theme_mod( 'ut_site_logo_alt' ) : get_theme_mod( 'ut_site_logo' );
$alternate_logo = get_theme_mod( 'ut_site_logo_alt' ) ? get_theme_mod( 'ut_site_logo_alt' ) : get_theme_mod( 'ut_site_logo' ) ;?>
<div class="site-logo">
<img data-altlogo="<?php echo $alternate_logo; ?>" src="<?php echo $sitelogo; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</div>
<?php else : ?>
<div class="site-logo">
<h1 class="logo"><?php bloginfo( 'name' ); ?></h1>
</div>
<?php endif; ?>
</div>
<?php
/* main and mobile menu cache */
if( ot_get_option('ut_use_cache' , 'off') == 'on' ) {
$language_prefix = defined('ICL_LANGUAGE_CODE') ? '_' . ICL_LANGUAGE_CODE : '';
$main_menu = get_transient('ut_main_menu' . get_the_ID() . $language_prefix );
$mobile_menu = get_transient('ut_mobile_menu' . get_the_ID() . $language_prefix );
$cacheTime = ot_get_option('ut_cache_ltime' , '10');
if ($main_menu === false) {
$main_menu = wp_nav_menu( $mainmenu );
set_transient('ut_main_menu' . get_the_ID() . $language_prefix , $main_menu, 60*$cacheTime);
}
if ($mobile_menu === false) {
$mobile_menu = wp_nav_menu( $mobilemenu );
set_transient('ut_mobile_menu' . get_the_ID() . $language_prefix , $mobile_menu, 60*$cacheTime);
}
} else {
$main_menu = wp_nav_menu( $mainmenu );
$mobile_menu = wp_nav_menu( $mobilemenu );
} ?>
<?php if ( has_nav_menu( 'primary' ) ) : ?>
<?php echo $main_menu; ?>
<div class="ut-mm-trigger tablet-grid-50 mobile-grid-50 hide-on-desktop">
<button class="ut-mm-button"></button>
</div>
<?php echo $mobile_menu; ?>
<?php endif; ?>
</div>
</div><!-- close .ha-header-perspective -->
<?php if( $navigation_width == 'centered') :?>
</div>
<?php endif; ?>
</header><!-- close header -->
<div class="clear"></div>
<!-- Commented this out too --------------------->
<?php// get_template_part( 'template-part', 'hero' ); ?>
<!-- just in case commented this out-->
<?php // ut_before_content_hook(); // action hook, see inc/ut-theme-hooks.php ?>
<div id="main-content" class="wrap ha-waypoint" data-animate-up="ha-header-hide" data-animate-down="ha-header-small">
<a class="ut-offset-anchor" id="to-main-content"></a>
<div class="main-content-background">

WordPress: Display particular category on load with filters

I have a theme with a portfolio that uses filters (ALL, NEW, OLD) to display categories. However, on load, I wish for a particular ("new") category to be the ONLY category displayed.
Then if a user wishes to see past products, they'd click "OLD" and so on..
Please keep in mind that I would create another portfolio and that portfolio's new items would be displayed only on load at first.
I've attempted to find the answer for hours but I have yet to be able to find it.
Here is the code of the portfolio php page:
<?php
/**
* Taxonomy Template for the Portfolios
*/
?>
<?php get_header(); ?>
<?php
if ( $post ) :
$port = wp_get_post_terms( $post->ID, array('portfolios') );
$portfolio = $port[0];
$post_img_width = "";
$post_img_height = "";
global $mav_data; // fetch options stored in $mav_data
$portfolio_order_1 = $mav_data['portfolio_order_1']; // date, title
$portfolio_order_2 = $mav_data['portfolio_order_2']; // ASC, DESC
$tax_query[] = array(
//'taxonomy' => $wp_query->query_vars['taxonomy'],
'taxonomy' => 'portfolios',
'field' => 'slug',
'terms' => array( $portfolio->slug )
);
$args = array(
'post_type'=> 'project',
'posts_per_page'=> -1,
'orderby' => $portfolio_order_1,
'order' => $portfolio_order_2,
'tax_query' => $tax_query
);
$port_query = new WP_Query($args);
?>
<?php
$tag_extra_fields = get_option('portfolios_fields');
$portfolio_layout = $tag_extra_fields[$portfolio->term_id]['_portfolio_layout'];
?>
<section id="content" class="portfolio one-column <?php echo esc_attr( $portfolio_layout ); ?>" role="main">
<div class="wrapper clearfix">
<header class="page-header">
<h1 class="entry-title"><?php echo( $portfolio->name ); ?></h1>
<?php if ($portfolio->description) { ?><p class="portfolio-header-description"><?php echo( $portfolio->description ); ?></p><?php } ?>
<?php
$temp = array();
foreach ( $posts as $post ) {
$temp_args = array();
while ($port_query->have_posts()) : $port_query->the_post(); // the loop begins, we need it here. It's important!!
$temp_cats = wp_get_object_terms( $post->ID, 'project_category'/*, $args*/ );
if ( $temp_cats ) {
foreach ( $temp_cats as $temp_cat ) {
if ( ! in_array( $temp_cat->slug, $temp ) ) {
$temp[] = $temp_cat->slug;
$categories[] = $temp_cat;
}
}
}
endwhile;
}
// DAHEX
$temp = array();
if(!empty($categories)) {
foreach ( $categories as $category ) {
$temp[] = array ('term_id'=>$category->term_id,'name'=>$category->name,'slug'=>$category->slug,'term_group'=>$category->term_group,'term_taxonomy_id'=>$category->term_taxonomy_id,'taxonomy'=>$category->taxonomy,'description'=> $category->description,'parent'=>$category->parent,'count'=> $category->count);
}
}
usort($temp, array(new Sorter('slug'), 'sort')); // Sorting Array by slug
$categories = array();
foreach ( $temp as $category ){
$categories[] =(object) $category;
}
// DAHEX
if(!empty($categories)) {
if(!is_wp_error( $categories )){
echo( '<ul id="filters" class="option-set">
<li>All</li>' );
foreach ( $categories as $category ) {
echo '<li><span class="sep">/</span>' . $category->name . '</li>';
}
echo( '</ul> <!-- /end #filters -->' );
} else {
echo '<span class="ooops">';
_e( 'Ooops! nothing found...', 'mav_framework' );
echo '</span>';
}
}
?>
</header> <!-- /end .page-header -->
<section id="projects">
<?php
while ($port_query->have_posts()) : $port_query->the_post(); // the loop begins
$terms = get_the_terms( get_the_ID(), 'project_category' );
$terms = $terms == false ? array() : $terms;
?>
<?php
$custom = get_post_custom($post->ID);
$portfolio_permalink = $custom["project_permalink"][0];
$portfolio_desc = $custom["project_desc"][0];
if ( !isset( $lightbox_path ) ) {
$lightbox_path = '';
}
// Prepare Project Image Thumb
$project_img = $custom["project_img"][0];
$project_img_ID = $custom['project_img_ID'][0];
// Need some proof check to ensure that no "notice" is thrown ...
if ( ! empty( $portfolio ) ) {
$term_slug = $portfolio->slug;
if ( isset( $custom["lightbox_path"][0] ) ) {
$lightbox_path = $custom["lightbox_path"][0];
} else {
$lightbox_path = '';
}
$empty_thumb = '<img class="portfolios_single_thumb portfolio-image" src="' . get_template_directory_uri() . '/images/thumb.png" width="' . $post_img_width . '" height="' . $post_img_height . '" alt="' . $post->post_title . '" />';
if ( isset( $project_img_ID ) ) {
if ( is_numeric( $project_img_ID ) ) {
$thumb_ID = $project_img_ID;
$thumb = wp_get_attachment_image( $thumb_ID, 'mav-thumbnails', false, array( 'class' => 'portfolios_post_image_thumb portfolio-image', 'alt' => $post->post_title ) );
if ( empty ($thumb) ) {
$thumb = $empty_thumb;
}
} elseif( $project_img_ID != "" ) {
$thumb = '<div class="project_iframe_thumb-$term_slug"><iframe width="' . $post_img_width . '" height="' . $post_img_height . '" src="' . $project_img . '" title="' . $project_img_ID . '" frameborder="0" allowfullscreen></iframe></div>';
} else {
$thumb = $empty_thumb;
}
} else {
$thumb = $empty_thumb;
}
}
?>
<article id="project-<?php the_ID(); ?>" class="element <?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->slug)). ' '; } ?>">
<?php
/**
* Generate the Project Image (Thumb)
*/
if ( $lightbox_path != '' ) { ?>
<figure class="thumb-container">
<a href="<?php echo esc_attr( $lightbox_path ); ?>" data-rel="prettyPhoto" title="<?php the_title_attribute(); ?>">
<span class="overlay lightbox"></span>
<?php mav_framework_project_label( $post, array( 'portfolios-project-label' ) ); ?>
<?php echo( $thumb ); ?>
</a>
</figure> <!-- /end .thumb-container -->
<?php
} elseif ($portfolio_permalink) {
?>
<figure class="thumb-container">
<a target="_blank" href="<?php echo esc_attr( $portfolio_permalink ); ?>" rel="bookmark">
<span class="overlay link"></span>
<?php mav_framework_project_label( $post, array( 'portfolios-project-label' ) ); ?>
<?php echo( $thumb ); ?>
</a>
</figure> <!-- /end .thumb-container -->
<?php } else { ?>
<figure class="thumb-container">
<a href="<?php the_permalink() ?>" rel="bookmark">
<span class="overlay">
<span class="view"><?php _e( 'View', 'mav_framework' ); ?></span>
</span>
<?php mav_framework_project_label( $post, array( 'portfolios-project-label' ) ); ?>
<?php echo( $thumb ); ?>
</a>
</figure> <!-- /end .thumb-container -->
<?php } // end Generate the Project Image (Thumb) ?>
<h2 class="project-title">
<?php if ($portfolio_permalink) { ?>
<a target="_blank" href="<?php echo esc_url( $portfolio_permalink ); ?>" rel="bookmark"><?php the_title(); ?></a>
<?php } else { ?>
<?php the_title(); ?>
<?php } ?>
</h2>
<?php if ($portfolio_desc) { ?><p class="project-description"><?php echo do_shortcode(stripslashes($portfolio_desc)); ?></p><?php } ?>
<footer class="entry-meta">
<span class="posted-on">
<?php _e( '<span class="posted-on-title">Posted on: </span>', 'mav_framework' ); ?><?php /* http://codex.wordpress.org/Formatting_Date_and_Time */ echo get_the_date('F j, Y'); ?>
</span> <!-- /end .posted-on -->
<?php
$project_categories = wp_get_object_terms($post->ID, 'project_category');
if ($project_categories) { ?>
<span class="cat-links">
<?php
_e( '<span class="cat-links-title">Category: </span>', 'mav_framework' );
$project_category = array();
foreach($project_categories as $category) {
$project_category[] = '' . $category->name . '';
}
echo implode(', ', $project_category);
?>
</span> <!-- /end .cat-links -->
<?php } ?>
<?php // Project Tags
$project_tags = wp_get_object_terms($post->ID, 'project_tag');
if ($project_tags) {
$project_tag = array();
foreach($project_tags as $tag) {
$project_tag[] = '' . $tag->name . '';
} ?>
<span class="tag-links">
<?php _e( '<span class="tag-links-title">Tagged: </span>', 'mav_framework' ); ?> <?php echo implode(', ', $project_tag); ?>
</span> <!-- /end .tag-links -->
<?php } ?>
</footer> <!-- /end .entry-meta -->
</article> <!-- /end #project-<?php the_ID(); ?> .element -->
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</section> <!-- /end #projects -->
</div> <!-- /end .wrapper -->
</section> <!-- /end #content -->
<?php endif; ?>
<?php
/**
* Add portfolio bottom quote
*/
if ( $mav_data['portfolio_quote_text'] ) : ?>
<section id="portfolio-quote" class="clearfix">
<div class="wrapper clearfix">
<?php get_template_part( 'inc/block_portfolio_quote' ); ?>
</div> <!-- /end .wrapper -->
</section> <!-- /end #portfolio-quote -->
<?php endif; ?>
<?php get_footer(); ?>
This problem is not related with the Wordpress itself but with the plugin that you, or your theme are using to sort the data.
In this case, it's using Isotope, which is what is filtering the results you see on the page.
By addressing the Isotope's documentation in terms of filtering, we see that the filters can be done through functions or buttons, in this case we're using a combination of both as we want the data to change while clicking but at the same time it already needs to come filtered, as you requested.
So, to solve the problem, it's one line in the isotope's function file:
$container.isotope({
itemSelector : '.element',
filter: '.workshops'
});
I just added the last one.
Apart from this, you just need to hack the code you provided in order to add the "selected" class to the button:
echo( '<ul id="filters" class="option-set">
<li>All</li>' );
foreach ( $categories as $category ) { ?>
<li>
<span class="sep">/</span>
<?php echo $category->name;?>
</li>
<?php
}
echo( '</ul>' );
Now some considerations:
If you change the slug, this will stop working as it's checking for the class "workshops", if you do it, you need to edit the code provided above;
Isotope was masked inside your theme's custom jquery file, which is not a good practice at all, specially for maintenance issues.

Categories