My page is bewitcheryinc.com
I am trying to re-arrange my home page. I need to switch the promotional area (section with 3 rectangles) with the text below it. I need to have the text displayed first and then the promotional area (section with 3 rectangles). I have contacted theme support, and they told me that the content is dynamic and the only solution to try is to replace header.php with the following code.
<?php
/**
* Displays the header content
*
* #package Theme Freesia
* #subpackage Edge
* #since Edge 1.0
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<?php
$edge_settings = edge_get_theme_options(); ?>
<head>
<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>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<!-- Masthead ============================================= -->
<header id="masthead" class="site-header">
<?php if ( function_exists( 'the_custom_header_markup' ) ) {
if ( is_header_video_active() && ( has_header_video() || is_customize_preview() ) ) {
echo '<div class="custom-header">
<div class="custom-header-media">';
the_custom_header_markup();
echo '</div>
</div>';
}else{
if ( has_header_image() ) {?>
<img src="<?php header_image(); ?>" class="header-image" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" />
<?php }
}
} else { ?>
<img src="<?php header_image(); ?>" class="header-image" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" />
<?php } ?>
<div class="top-header">
<div class="container clearfix">
<?php
if( is_active_sidebar( 'edge_header_info' )) {
dynamic_sidebar( 'edge_header_info' );
}
if($edge_settings['edge_top_social_icons'] == 0):
echo '<div class="header-social-block">';
do_action('social_links');
echo '</div>'.'<!-- end .header-social-block -->';
endif;
do_action('edge_site_branding'); ?>
</div> <!-- end .container -->
</div> <!-- end .top-header -->
<!-- Main Header============================================= -->
<div id="sticky_header">
<div class="container clearfix">
<h3 class="nav-site-title">
<?php bloginfo('name');?>
</h3>
<!-- end .nav-site-title -->
<!-- Main Nav ============================================= -->
<?php
if (has_nav_menu('primary')) { ?>
<?php $args = array(
'theme_location' => 'primary',
'container' => '',
'items_wrap' => '<ul id="primary-menu" class="menu nav-menu">%3$s</ul>',
); ?>
<nav id="site-navigation" class="main-navigation clearfix">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
<span class="line-one"></span>
<span class="line-two"></span>
<span class="line-three"></span>
</button>
<!-- end .menu-toggle -->
<?php wp_nav_menu($args);//extract the content from apperance-> nav menu ?>
</nav> <!-- end #site-navigation -->
<?php } else {// extract the content from page menu only ?>
<nav id="site-navigation" class="main-navigation clearfix">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
<span class="line-one"></span>
<span class="line-two"></span>
<span class="line-three"></span>
</button>
<!-- end .menu-toggle -->
<?php wp_page_menu(array('menu_class' => 'menu', 'items_wrap' => '<ul id="primary-menu" class="menu nav-menu">%3$s</ul>')); ?>
</nav> <!-- end #site-navigation -->
<?php }
$search_form = $edge_settings['edge_search_custom_header'];
if (1 != $search_form) { ?>
<div id="search-toggle" class="header-search"></div>
<div id="search-box" class="clearfix">
<?php get_search_form();?>
</div> <!-- end #search-box -->
<?php }
echo '</div> <!-- end .container -->
</div> <!-- end #sticky_header -->';
$enable_slider = $edge_settings['edge_enable_slider'];
edge_slider_value();
if ($enable_slider=='frontpage'|| $enable_slider=='enitresite'){
if(is_front_page() && ($enable_slider=='frontpage') ) {
if($edge_settings['edge_slider_type'] == 'default_slider') {
edge_page_sliders();
}else{
if(class_exists('Edge_Plus_Features')):
edge_image_sliders();
endif;
}
}
if($enable_slider=='enitresite'){
if($edge_settings['edge_slider_type'] == 'default_slider') {
edge_page_sliders();
}else{
if(class_exists('Edge_Plus_Features')):
edge_image_sliders();
endif;
}
}
} ?>
</header> <!-- end #masthead -->
<!-- Main Page Start ============================================= -->
<div id="content">
<div class="container clearfix">
<?php
if(is_front_page()){
if( have_posts() ) {
while( have_posts() ) {
the_post();
get_template_part( 'content', get_post_format() );
}
} else { ?>
<h2 class="entry-title"> <?php esc_html_e( 'No Posts Found.', 'edge' ); ?> </h2>
<?php }
do_action('edge_display_frontpage_features');
}
if(!is_home()){?>
<div class="page-header">
<h1 class="page-title"><?php echo edge_header_title(); ?></h1>
<!-- .page-title -->
<?php edge_breadcrumb(); ?>
<!-- .breadcrumb -->
</div>
<!-- .page-header -->
<?php }
After I replace headr.php, I have to add the following css:
.home .entry-header, .home .entry-meta, section#post-417, .home .entry-footer {
display:none;
}
When I follow these instructions, the home page displays my original page text as a blog post with "read more" tags, along with the meta tags. The read more link links back to the home page. I simply want the front page to display my page title, some text, and then the promotional picture boxes.
If it is helpful, I beleive that when promotional area is turned on, the theme uses front-page-feature.php template instead of an index page. It is bellow.
<?php
function edge_frontpage_features(){
$edge_settings = edge_get_theme_options();
if($edge_settings['edge_disable_features'] != 1){
$edge_features = '';
$edge_total_page_no = 0;
$edge_list_page = array();
for( $i = 1; $i <= $edge_settings['edge_total_features']; $i++ ){
if( isset ( $edge_settings['edge_frontpage_features_' . $i] ) && $edge_settings['edge_frontpage_features_' . $i] > 0 ){
$edge_total_page_no++;
$edge_list_page = array_merge( $edge_list_page, array( $edge_settings['edge_frontpage_features_' . $i] ) );
}
}
if ( !empty( $edge_list_page ) && $edge_total_page_no > 0 ) {
echo '<!-- Promotional Area ============================================= -->';
$edge_features .= '<div class="promonational-area">';
$get_featured_posts = new WP_Query(array(
'posts_per_page' => $edge_settings['edge_total_features'],
'post_type' => array('page'),
'post__in' => $edge_list_page,
'orderby' => 'post__in',
));
$edge_features .= '<div class="column clearfix">';
$j = 1;
while ($get_featured_posts->have_posts()):$get_featured_posts->the_post();
$attachment_id = get_post_thumbnail_id();
$image_attributes = wp_get_attachment_image_src($attachment_id,'pixgraphy_promotional_image');
$excerpt = get_the_excerpt();
$edge_features .= '<div class="three-column">';
if ($image_attributes) {
$edge_features .= '<div class="promonational-img" title="'.the_title('', '', false).'"' .' style="background-image:url(' ."'" .esc_url($image_attributes[0])."'" .')"> <a class="promonational-link" href="'.get_the_permalink().'"></a> ';
$edge_features .= '<div class="promonational-overlay">
<h4>'.get_the_title().'</h4></div></div>';
}
$edge_features .='</div><!-- end .three-column -->';
$j++;
endwhile;
$edge_features .='</div><!-- .end column-->';
$edge_features .='</div><!-- end .promonational-area -->';
}
echo $edge_features;
}
wp_reset_postdata();
}
add_action('edge_display_frontpage_features','edge_frontpage_features');
Can anyone help? I am not proficient obviously in PHP/WordPress at all. Thank you!
I think this would work:
In index.php move the
if(is_front_page()){
do_action('edge_display_frontpage_features');
}
right before
get_template_part( 'pagination', 'none' );
in header.php.
This would put the front-page feature after the 'main' content in the primary section of the post. Now you need to figure out how to put the right post content for the text. Currently it seems like it's not fetching the correct post type. It's probably the sample post in the post post type.
But is the text supposed to be static or changes with your recently posted content? If its supposed to static, you should go in Settings->Reading in the admin dashboard and set the front-page to a static page and then you can put in the text into that page content.
Related
Looking for help in getting my wordpress theme to display header image on all pages and not just the home page as it currently does. All pages use get_header php command and the header.php contains the following code:
<?php
/**
* The header for our theme
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* #link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* #package Superb_Landingpage
*/
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div class="navigation-wrapper">
<div class="site grid-container">
<header id="masthead" class="site-header grid-x grid-padding-x">
<div class="site-branding large-4 medium-10 small-9 cell">
<?php
the_custom_logo();
if ( is_front_page() && is_home() && is_page() ) :
?>
<div class="logo-container">
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<?php
else :
?>
<div class="logo-container">
<h2 class="site-title"><?php bloginfo( 'name' ); ?></h2>
<?php
endif;
$superb_landingpage_description = get_bloginfo( 'description', 'display' );
if ( $superb_landingpage_description || is_customize_preview() ) :
?>
<p class="site-description"><?php echo $superb_landingpage_description; /* WPCS: xss ok. */ ?></p>
<?php endif; ?>
</div>
</div><!-- .site-branding -->
<nav id="site-navigation" class="main-navigation large-8 medium-2 small-3 cell">
<?php
wp_nav_menu( array(
'theme_location' => 'menu-1',
'menu_id' => 'primary-menu',
) );
?>
</nav><!-- #site-navigation -->
</header><!-- #masthead -->
</div>
</div>
<?php if ( get_header_image() ) : ?>
<?php if ( is_front_page() ) : ?>
<div class="content-wrap">
<div class="bottom-header-wrapper">
<img src="<?php echo esc_url(( get_header_image()) ); ?>" alt="<?php echo esc_attr(( get_bloginfo( 'title' )) ); ?>" />
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<div id="page" class="site grid-container start-container-head">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'superb-landingpage' ); ?></a>
<div id="content" class="site-content grid-x grid-padding-x">
What do I add/remove to simply have the header display on all pages?
I've tried removing the if/else conditions in the header.php but wordpress keeps rolling back the edit claiming errors. Any help is greatly appreciated! Thank you.
Try it
<?php
if ( is_home() ) {
// This is a homepage
} else {
// This is not a homepage
}
?>
<?php
if ( is_front_page() && is_home() ) {
// This is a homepage
} else {
// This is not a homepage
}
?>
If this does not work try this
<?php
if ( is_front_page() ) {
// This is a homepage
} else {
// This is not a homepage
}
?>
Hi dear programming and PHP geniuses,
I'm new to php and effed up a search form on my Wordpress shop page (wich isn't public yet). After searching for the error for days I still have no clue where the error might be. I installed SublimeText + SublimeLinter to find a syntax error, but apparently there is none ...
The search form closes as soon as I try to type something in (as soon as I click in it).
I use the Mr. Tailor Theme: http://themeforest.net/item/mr-tailor-responsive-woocommerce-theme/full_screen_preview/7292110
So, here is the code (it's quite long and I'm not sure if this alone helps, so please let me know if I have to add anything):
<?php global $woocommerce, $mr_tailor_theme_options; ?>
<footer id="site-footer" role="contentinfo">
<div id="own_footer">
<img src="../../image_assets/logo_footer.png" alt="Logo">
<br><br><br>
<p>Folgen Sie uns auf: </p>
<img src="../../image_assets/instagram_footer.png" alt="Logo" >
<img src="../../image_assets/facebook_footer.png" alt="Logo" >
<img src="../../image_assets/pinterest_footer.png" alt="Logo" >
<br><br><br>
</div>
<br><br>
<p id="newsletter_copy">
NEWSLETTER
<br><br>
Sie haben Interesse an unserem Newsletter und möchten regelmäßig über neue Produkte,
Sonderangebote und andere tolle Sachen informiert werden? Dann registrieren Sie sich für unseren
Newsletter.
</p>
<div id="footer_eingabefeld">
<?php if ( is_active_sidebar( 'footer-widget-area' ) ) : ?>
<div class="trigger-footer-widget-area">
<span class="trigger-footer-widget-icon"></span>
</div>
<div class="site-footer-widget-area">
<div class="row">
<?php dynamic_sidebar( 'footer-widget-area' ); ?>
</div><!-- .row -->
</div><!-- .site-footer-widget-area -->
<?php endif; ?>
<div id="footer_links">
<li>Über Fuchs und Feder</li>
<li>Kontakt</li>
<li>FAQ</li>
<li>Impressum</li>
<li>Mein Konto</li>
</div>
<div class="site-footer-copyright-area">
<div class="row">
<div class="medium-4 columns">
<div class="payment_methods">
<?php
if ( (isset($mr_tailor_theme_options['credit_card_icons']['url'])) && (trim($mr_tailor_theme_options['credit_card_icons']['url']) != "" ) ) {
if (is_ssl()) {
$credit_card_icons = str_replace("http://", "https://", $mr_tailor_theme_options['credit_card_icons']['url']);
} else {
$credit_card_icons = $mr_tailor_theme_options['credit_card_icons']['url'];
}
?>
<img src="<?php echo $credit_card_icons; ?>" alt="<?php _e( 'Payment methods', 'mr_tailor' )?>" />
<?php } ?>
</div><!-- .payment_methods -->
</div><!-- .large-4 .columns -->
<div class="medium-8 columns">
<div class="copyright_text">
<?php if ( (isset($mr_tailor_theme_options['footer_copyright_text'])) && (trim($mr_tailor_theme_options['footer_copyright_text']) != "" ) ) { ?>
<?php _e( $mr_tailor_theme_options['footer_copyright_text'], 'mr_tailor' ); ?>
<?php } ?>
</div><!-- .copyright_text -->
</div><!-- .large-8 .columns -->
</div><!-- .row -->
</div><!-- .site-footer-copyright-area -->
</footer>
</div><!-- #page -->
</div><!-- /st-content -->
</div><!-- /st-pusher -->
<nav class="st-menu slide-from-left">
<div class="nano">
<div class="nano-content">
<div id="mobiles-menu-offcanvas" class="offcanvas-left-content">
<nav id="mobile-main-navigation" class="mobile-navigation" role="navigation">
<?php
wp_nav_menu(array(
'theme_location' => 'main-navigation',
'fallback_cb' => false,
'container' => false,
'items_wrap' => '<ul id="%1$s">%3$s</ul>',
));
?>
</nav>
<?php
$theme_locations = get_nav_menu_locations();
if (isset($theme_locations['top-bar-navigation'])) {
$menu_obj = get_term($theme_locations['top-bar-navigation'], 'nav_menu');
}
if ( (isset($menu_obj->count) && ($menu_obj->count > 0)) || (is_user_logged_in()) ) {
?>
<nav id="mobile-top-bar-navigation" class="mobile-navigation" role="navigation">
<?php
wp_nav_menu(array(
'theme_location' => 'top-bar-navigation',
'fallback_cb' => false,
'container' => false,
'items_wrap' => '<ul id="%1$s">%3$s</ul>',
));
?>
<?php if ( is_user_logged_in() ) { ?>
<ul><li><?php _e('Logout', 'mr_tailor'); ?></li></ul>
<?php } ?>
</nav>
<?php } ?>
<div class="language-and-currency-offcanvas hide-for-large-up">
<?php if (function_exists('icl_get_languages')) { ?>
<?php $additional_languages = icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str'); ?>
<select class="topbar-language-switcher">
<option><?php echo ICL_LANGUAGE_NAME; ?></option>
<?php
if (count($additional_languages) > 1) {
foreach($additional_languages as $additional_language){
if(!$additional_language['active']) $langs[] = '<option value="'.$additional_language['url'].'">'.$additional_language['native_name'].'</option>';
}
echo join(', ', $langs);
}
?>
</select>
<?php } ?>
<?php if (class_exists('woocommerce_wpml')) { ?>
<?php echo(do_shortcode('[currency_switcher]')); ?>
<?php } ?>
</div>
<div class="mobile-socials">
<div class="site-social-icons">
<ul class="//animated //flipY">
<?php if ( (isset($mr_tailor_theme_options['facebook_link'])) && (trim($mr_tailor_theme_options['facebook_link']) != "" ) ) { ?><li class="site-social-icons-facebook"><a target="_blank" href="<?php echo $mr_tailor_theme_options['facebook_link']; ?>"><i class="fa fa-facebook"></i><span>Facebook</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['twitter_link'])) && (trim($mr_tailor_theme_options['twitter_link']) != "" ) ) { ?><li class="site-social-icons-twitter"><a target="_blank" href="<?php echo $mr_tailor_theme_options['twitter_link']; ?>"><i class="fa fa-twitter"></i><span>Twitter</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['pinterest_link'])) && (trim($mr_tailor_theme_options['pinterest_link']) != "" ) ) { ?><li class="site-social-icons-pinterest"><a target="_blank" href="<?php echo $mr_tailor_theme_options['pinterest_link']; ?>"><i class="fa fa-pinterest"></i><span>Pinterest</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['linkedin_link'])) && (trim($mr_tailor_theme_options['linkedin_link']) != "" ) ) { ?><li class="site-social-icons-linkedin"><a target="_blank" href="<?php echo $mr_tailor_theme_options['linkedin_link']; ?>"><i class="fa fa-linkedin"></i><span>LinkedIn</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['googleplus_link'])) && (trim($mr_tailor_theme_options['googleplus_link']) != "" ) ) { ?><li class="site-social-icons-googleplus"><a target="_blank" href="<?php echo $mr_tailor_theme_options['googleplus_link']; ?>"><i class="fa fa-google-plus"></i><span>Google+</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['rss_link'])) && (trim($mr_tailor_theme_options['rss_link']) != "" ) ) { ?><li class="site-social-icons-rss"><a target="_blank" href="<?php echo $mr_tailor_theme_options['rss_link']; ?>"><i class="fa fa-rss"></i><span>RSS</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['tumblr_link'])) && (trim($mr_tailor_theme_options['tumblr_link']) != "" ) ) { ?><li class="site-social-icons-tumblr"><a target="_blank" href="<?php echo $mr_tailor_theme_options['tumblr_link']; ?>"><i class="fa fa-tumblr"></i><span>Tumblr</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['instagram_link'])) && (trim($mr_tailor_theme_options['instagram_link']) != "" ) ) { ?><li class="site-social-icons-instagram"><a target="_blank" href="<?php echo $mr_tailor_theme_options['instagram_link']; ?>"><i class="fa fa-instagram"></i><span>Instagram</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['youtube_link'])) && (trim($mr_tailor_theme_options['youtube_link']) != "" ) ) { ?><li class="site-social-icons-youtube"><a target="_blank" href="<?php echo $mr_tailor_theme_options['youtube_link']; ?>"><i class="fa fa-youtube-play"></i><span>Youtube</span></a></li><?php } ?>
<?php if ( (isset($mr_tailor_theme_options['vimeo_link'])) && (trim($mr_tailor_theme_options['vimeo_link']) != "" ) ) { ?><li class="site-social-icons-vimeo"><a target="_blank" href="<?php echo $mr_tailor_theme_options['vimeo_link']; ?>"><i class="fa fa-vimeo-square"></i><span>Vimeo</span></a></li><?php } ?>
</ul>
</div>
</div>
</div>
<div id="filters-offcanvas" class="offcanvas-left-content wpb_widgetised_column">
<?php if ( is_active_sidebar( 'catalog-widget-area' ) ) : ?>
<?php dynamic_sidebar( 'catalog-widget-area' ); ?>
<?php endif; ?>
</div>
</div>
</div>
</nav>
<nav class="st-menu slide-from-right">
<div class="nano">
<div class="nano-content">
<div id="minicart-offcanvas" class="offcanvas-right-content"><?php if ( class_exists( 'WC_Widget_Cart' ) ) { the_widget( 'mr_tailor_WC_Widget_Cart' ); } ?></div>
<div id="wishlist-offcanvas" class="offcanvas-right-content"><div class="widget"></div></div>
</div>
</div>
</nav>
</div><!-- /st-container -->
<!-- ******************************************************************** -->
<!-- * Custom Footer JavaScript Code ************************************ -->
<!-- ******************************************************************** -->
<?php if ( (isset($mr_tailor_theme_options['footer_js'])) && ($mr_tailor_theme_options['footer_js'] != "") ) : ?>
<script type="text/javascript">
<?php echo $mr_tailor_theme_options['footer_js']; ?>
</script>
<?php endif; ?>
<?php if ( (isset($mr_tailor_theme_options['sticky_header'])) && (trim($mr_tailor_theme_options['sticky_header']) == "1" ) ) : ?>
<!-- ******************************************************************** -->
<!-- * Sticky Header **************************************************** -->
<!-- ******************************************************************** -->
<div class="site-header-sticky">
<div class="row">
<div class="large-12 columns">
<div class="site-header-sticky-inner">
<div class="site-branding">
<?php
if ( (isset($mr_tailor_theme_options['site_logo']['url'])) && (trim($mr_tailor_theme_options['site_logo']['url']) != "" ) ) {
if (is_ssl()) {
$site_logo = str_replace("http://", "https://", $mr_tailor_theme_options['site_logo']['url']);
} else {
$site_logo = $mr_tailor_theme_options['site_logo']['url'];
}
?>
<img class="site-logo" src="<?php echo $site_logo; ?>" title="<?php bloginfo( 'description' ); ?>" alt="<?php bloginfo( 'name' ); ?>" />
<?php } else { ?>
<div class="site-title"><?php bloginfo( 'name' ); ?></div>
<?php } ?>
</div><!-- .site-branding -->
<?php
if ( (isset($mr_tailor_theme_options['site_logo_retina']['url'])) && (trim($mr_tailor_theme_options['site_logo_retina']['url']) != "" ) ) {
?>
<script>
//<![CDATA[
// Set pixelRatio to 1 if the browser doesn't offer it up.
var pixelRatio = !!window.devicePixelRatio ? window.devicePixelRatio : 1;
logo_image = new Image();
jQuery(window).load(function(){
if (pixelRatio > 1) {
jQuery('.site-logo').each(function() {
var logo_image_width = jQuery(this).width();
var logo_image_height = jQuery(this).height();
jQuery(this).css("width", logo_image_width);
jQuery(this).css("height", logo_image_height);
jQuery(this).attr('src', '<?php echo $mr_tailor_theme_options['site_logo_retina']['url'] ?>');
});
};
});
//]]>
</script>
<?php } ?>
<div id="site-menu">
<nav id="site-navigation" class="main-navigation" role="navigation">
<?php
wp_nav_menu(array(
'theme_location' => 'main-navigation',
'fallback_cb' => false,
'container' => false,
'items_wrap' => '<ul id="%1$s">%3$s</ul>',
));
?>
</nav><!-- #site-navigation -->
<div class="site-tools">
<ul>
<li class="mobile-menu-button"><a><i class="getbowtied-icon-menu"></i></a></li>
<?php if (class_exists('YITH_WCWL')) : ?>
<?php if ( (isset($mr_tailor_theme_options['main_header_wishlist'])) && (trim($mr_tailor_theme_options['main_header_wishlist']) == "1" ) ) : ?>
<li class="wishlist-button"><a><i class="getbowtied-icon-heart"></i></a><span class="wishlist_items_number"><?php echo yith_wcwl_count_products(); ?></span></li>
<?php endif; ?>
<?php endif; ?>
<?php if (class_exists('WooCommerce')) : ?>
<?php if ( (isset($mr_tailor_theme_options['main_header_shopping_bag'])) && (trim($mr_tailor_theme_options['main_header_shopping_bag']) == "1" ) ) : ?>
<?php if ( (isset($mr_tailor_theme_options['catalog_mode'])) && ($mr_tailor_theme_options['catalog_mode'] == 1) ) : ?>
<?php else : ?>
<li class="shopping-bag-button" class="right-off-canvas-toggle"><a><i class="getbowtied-icon-shop"></i></a><span class="shopping_bag_items_number"><?php echo $woocommerce->cart->cart_contents_count; ?></span></li>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php if ( (isset($mr_tailor_theme_options['main_header_search_bar'])) && (trim($mr_tailor_theme_options['main_header_search_bar']) == "1" ) ) : ?>
<li class="search-button"><a><i class="getbowtied-icon-search"></i></a></li>
<?php endif; ?>
</ul>
</div>
<div class="site-search">
<?php
if (class_exists('WooCommerce')) {
the_widget( 'WC_Widget_Product_Search', 'title=' );
} else {
the_widget( 'WP_Widget_Search', 'title=' );
}
?>
</div><!-- .site-search -->
</div><!-- #site-menu -->
<div class="clearfix"></div>
</div><!--.site-header-sticky-inner-->
</div><!-- .large-12-->
</div><!--.row-->
</div><!-- .site-header-sticky -->
<?php endif; ?>
<!-- ******************************************************************** -->
<!-- * WP Footer() ****************************************************** -->
<!-- ******************************************************************** -->
<div class="login_header">
<a class="go_home" href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a>
</div>
<?php wp_footer(); ?>
</body>
</html>
Weird thing is also, that this code is from the footer.php, but still it apparently influences the search bar....
I know it's kinda like dynamite fishing, but I just ran out of ideas. So thank you all in advance!
You are referencing the event targets id but the event target does not have an id set. If you inspect your code, the search input element has no id set.
scripts.js(143):
$("body").on('click',function(e) {
if($(e.target).attr('class') == 'getbowtied-icon-search'
|| $(e.target).attr('id') == 's') {
return;
} else {
reset_search_toggles()
$('body').unbind('click');
}
});
If you can not add an id to that element for whatever reason you can also search by its name(I do not advise this, id's are much better).
if($(e.target).attr('class') == 'getbowtied-icon-search'
|| $(e.target).attr('id') == 's'
|| $(e.target).attr('name') == 's') {
I have a theme that shows the latest four posts in one column. I want to convert this to two posts in two columns.
I made two divs next to each other and put the first in descending order and the other in ascending order. Then I set it to show only 2 posts.
But now it shows 2 posts in the left div and all four posts in the right div:
I don't understand why it is doing this. Here is the code:
<section class="container">
<div class="left-half">
<article>
<!-- =========================
SECTION: LATEST NEWS
============================== -->
<?php
$parallax_number_of_posts = get_option('posts_per_page');
$args = array( 'post_type' => 'post', 'posts_per_page' => $parallax_number_of_posts, 'order' => 'ASC','ignore_sticky_posts' => true );
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
$parallax_one_latest_news_title = get_theme_mod('parallax_one_latest_news_title',esc_html__('Latest news','parallax-one'));
if($parallax_number_of_posts > 0) {
?>
<section class="brief timeline" id="latestnews" role="region" aria-label="<?php esc_html_e('Latest blog posts','parallax-one'); ?>">
<div class="section-overlay-layer">
<div align="center" class="container">
<div class="row">
<!-- TIMELINE HEADING / TEXT -->
<?php
if(!empty($parallax_one_latest_news_title)){
echo '<div class="col-md-12 timeline-text text-left"><h2 class="text-left dark-text">'.esc_attr($parallax_one_latest_news_title).'</h2><div class="colored-line-left"></div></div>';
} elseif ( isset( $wp_customize ) ) {
echo '<div class="col-md-12 timeline-text text-left paralax_one_only_customizer"><h2 class="text-left dark-text "></h2><div class="colored-line-left "></div></div>';
}
?>
<div class="parallax-slider-whole-wrap">
<!--<div class="controls-wrap">
<button class="control_next icon icon-arrow-carrot-down"><span class="screen-reader-text"><?php esc_attr_e('Post slider navigation: Down','parallax-one')?></span></button>
<button class="control_prev fade-btn icon icon-arrow-carrot-up"><span class="screen-reader-text"><?php esc_attr_e('Post slider navigation: Up','parallax-one')?></span></button>
</div>-->
<!-- TIMLEINE SCROLLER -->
<div itemscope itemtype="http://schema.org/Blog" id="parallax_slider" class="col-md-6 timeline-section">
<ul class="vertical-timeline" id="timeline-scroll">
<?php
$i_latest_posts= 0;
while ( $the_query->have_posts() ) : $the_query->the_post();
$i_latest_posts++;
if ( !wp_is_mobile() ){
if($i_latest_posts % 2 == 1){
echo '<li>';
}
} else {
echo '<li>';
}
?>
<div itemscope itemprop="blogPosts" itemtype="http://schema.org/BlogPosting" id="post-<?php the_ID(); ?>" class="timeline-box-wrap" title="<?php printf( esc_html__( 'Latest News: %s', 'parallax-one' ), get_the_title() ) ?>">
<div itemscope itemprop="image" class="icon-container white-text">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php
if ( has_post_thumbnail() ) :
the_post_thumbnail('parallax-one-post-thumbnail-latest-news');
else: ?>
<img src="<?php echo parallax_get_file('/images/no-thumbnail-latest-news.jpg'); ?>" width="150" height="150" alt="<?php the_title(); ?>">
<?php
endif;
?>
</a>
</div>
<div class="info">
<header class="entry-header">
<h1 itemprop="headline" class="entry-title"><br><br><br>
<?php the_title(); ?>
</h1>
<!-- .entry-meta -->
</header>
<div itemprop="description" class="entry-content entry-summary">
<?php the_excerpt(); ?>
<?php printf( esc_html__( 'Bekijk de fotos %s', 'textdomain' ), '<span class="screen-reader-text"> '.get_the_title().'</span>' ); ?>
</div>
</div>
</div>
<?php
if ( !wp_is_mobile() ){
if($i_latest_posts % 2 == 0){
echo '</li>';
}
} else {
echo '</li>';
}
endwhile;
wp_reset_postdata();
?>
</ul>
</div>
</div><!-- .parallax-slider-whole-wrap -->
</div>
</div>
</div>
</section>
<?php
}
} ?>
</article>
</div>
<!--rechts-->
<div class="right-half">
<article>
<!-- =========================
SECTION: LATEST NEWS
============================== -->
<?php
$parallax_number_of_posts = get_option('posts_per_page');
$args = array( 'post_type' => 'post', 'posts_per_page' => $parallax_number_of_posts, 'order' => 'DESC','ignore_sticky_posts' => true );
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
$parallax_one_latest_news_title = get_theme_mod('parallax_one_latest_news_title',esc_html__('Latest news','parallax-one'));
if($parallax_number_of_posts > 0) {
?>
<section class="brief timeline" id="latestnews" role="region" aria-label="<?php esc_html_e('Latest blog posts','parallax-one'); ?>">
<div class="section-overlay-layer">
<div align="center" class="container">
<div class="row">
<!-- TIMELINE HEADING / TEXT -->
<br>
<br>
<br>
<div class="parallax-slider-whole-wrap">
<div class="controls-wrap">
<button class="control_next icon icon-arrow-carrot-down"><span class="screen-reader-text"><?php esc_attr_e('Post slider navigation: Down','parallax-one')?></span></button>
<button class="control_prev fade-btn icon icon-arrow-carrot-up"><span class="screen-reader-text"><?php esc_attr_e('Post slider navigation: Up','parallax-one')?></span></button>
</div>
<!-- TIMLEINE SCROLLER -->
<div itemscope itemtype="http://schema.org/Blog" id="parallax_slider" class="col-md-6 timeline-section">
<ul class="vertical-timeline" id="timeline-scroll">
<?php
$i_latest_posts= 0;
while ( $the_query->have_posts() ) : $the_query->the_post();
$i_latest_posts++;
if ( !wp_is_mobile() ){
if($i_latest_posts % 2 == 1){
echo '<li>';
}
} else {
echo '<li>';
}
?>
<div itemscope itemprop="blogPosts" itemtype="http://schema.org/BlogPosting" id="post-<?php the_ID(); ?>" class="timeline-box-wrap" title="<?php printf( esc_html__( 'Latest News: %s', 'parallax-one' ), get_the_title() ) ?>">
<div itemscope itemprop="image" class="icon-container white-text">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php
if ( has_post_thumbnail() ) :
the_post_thumbnail('parallax-one-post-thumbnail-latest-news');
else: ?>
<img src="<?php echo parallax_get_file('/images/no-thumbnail-latest-news.jpg'); ?>" width="150" height="150" alt="<?php the_title(); ?>">
<?php
endif;
?>
</a>
</div>
<div class="info">
<header class="entry-header">
<h1 itemprop="headline" class="entry-title"><br><br><br>
<?php the_title(); ?>
</h1>
<!-- .entry-meta -->
</header>
<div itemprop="description" class="entry-content entry-summary">
<?php the_excerpt(); ?>
<?php printf( esc_html__( 'Bekijk de fotos %s', 'textdomain' ), '<span class="screen-reader-text"> '.get_the_title().'</span>' ); ?>
</div>
</div>
</div>
<?php
if ( !wp_is_mobile() ){
if($i_latest_posts % 2 == 0){
echo '</li>';
}
} else {
echo '</li>';
}
endwhile;
wp_reset_postdata();
?>
</ul>
</div>
</div><!-- .parallax-slider-whole-wrap -->
</div>
</div>
</div>
</section>
<?php
}
} ?>
</article>
</div>
</section>
If I understood correctly what you want to achieve - to divide several posts into two columns, I can not understand exactly how you want to achieve this into code. If you rely on this condition $the_query->current_post % 2 == 1 to filter the posts, then in your code it only filter printing of the li element, but then the cycle continues and show the post itself, ie what you achieve with this code is to place two posts (div.timeline-box-wrap) elements in one li.If you want to use this method of separation, you should change the code a little (I will simplify it, but the main is, that you must stop current loop if your condition pass).
You don't need to query DB two times with the same query - this is performance issue, so you can use the same result and loop over two times.
You can use $the_query->current_post to get current post and filter.
<section class="container">
<div class="left-half">
<article>
<?php
$parallax_number_of_posts = get_option('posts_per_page');
$args = array( 'post_type' => 'product', 'posts_per_page' => $parallax_number_of_posts, 'order' => 'ASC','ignore_sticky_posts' => true );
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
if($parallax_number_of_posts > 0) {
?>
<section class="brief timeline" id="latestnews" role="region" aria-label="<?php esc_html_e('Latest blog posts','parallax-one'); ?>">
<ul class="vertical-timeline" id="timeline-scroll">
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
if($the_query->current_post % 2 == 1)
continue; ?>
<li><?php the_title() ?></li>
<?php endwhile; ?>
</ul>
</section>
<?php
}
} ?>
</article>
</div>
<div class="right-half">
<article>
<?php
$the_query->rewind_posts();
if ( $the_query->have_posts() ) {
if($parallax_number_of_posts > 0) {
?>
<section class="brief timeline" id="latestnews" role="region" aria-label="<?php esc_html_e('Latest blog posts','parallax-one'); ?>">
<ul class="vertical-timeline" id="timeline-scroll">
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
if($the_query->current_post % 2 == 0)
continue; ?>
<li><?php the_title() ?></li>
<?php endwhile; ?>
</ul>
</section>
<?php
}
} ?>
</article>
</div>
</section>
P.S. You can simplify more, if you set 2 variables: $left and $right and use only one loop to set one or other with html, and then print their values.
I'm using a wordpress theme as a base to provide horizontal parallax scrolling. I have everything working wonderfully, but when I try to pull the featured image into the page (see CONTENT), nothing will pull up. I can get a static image to show up, but not with any amount of tags or even custom fields. Here is the code for the page:
<?php
/**
* The main file.
*/
get_header(); ?>
<?php require( dirname( __FILE__ ) . "/inc/theme-options-vars.php" ); ?>
<!-- ==================== PARALLAX FUNCTIONS ==================== -->
<?php for( $i=1; $i<=($numposts); $i++ )
{
echo '<div class="hw" id="page-'.$i.'">';
} ?>
<!-- ==================== PARALLAX FUNCTIONS ==================== -->
<?php if($convax_bg1!==''){
echo'
<div class="elem-1">
<div class="elem-1-bg"></div>
</div>';
}
if($convax_bg2!==''){
echo'
<div class="elem-2">
<div class="elem-2-bg"></div>
</div>';
}
?>
<div class="hw" id="content-inner">
<?php
$pages = get_pages( 'sort_order=asc&sort_column=menu_order&depth=1' );
foreach ( $pages as $pag ) {
setup_postdata( $pag );
$new_title = str_replace( " ", "", strtolower( $pag->post_title ) );
$tempname = get_post_meta( $pag->ID, '_wp_page_template', true );
$filename = preg_replace('"\.php$"', '', $tempname);
echo '<div class="page '.$new_title;
echo '" id="' . $new_title . '"><div class="page-info">';
if ( $new_title !== 'home' ) {
echo '<h1>';
echo $pag->post_title;
$pag->post_title;
echo '</h1>';
}
?>
<!-- If Portfolio Page -->
<?php if($filename == 'page-portfolio'):?>
<?php query_posts( array( 'post_type' => 'portfolio_item', 'orderby' => 'date', 'order' => 'ASC' ) ); ?>
<?php if(have_posts()): ?>
<div class="scrollbar1">
<div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div>
</div></div></div>
<div class="viewport">
<div class="overview">
<div class="rec-proj">
<ul>
<?php while ( have_posts() ) : the_post(); ?>
<li>
<a href="#port-<?php echo $post->ID ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'convaxsolutions' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark" class="various">
<?php
if(has_post_thumbnail()) {
the_post_thumbnail('thumbnail');
} else {
echo '<img src="'.get_bloginfo("template_url").'/images/default-featured-image.png" class="portfolio-thumb" width="60" height="60"/>';
}
?>
</a>
<?php edit_post_link('Edit'); ?>
</li>
<?php endwhile; ?>
</ul>
</div><!-- / rec proj -->
</div><!-- / .overview -->
</div><!-- / .viewport -->
</div><!-- / .Scrollbar1 -->
<?php else: ?>
<h1 class="alert"></h1>
<?php endif; ?>
<?php else: ?>
<div class="scrollbar1">
<div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div> </div></div></div>
<div class="viewport">
<!-- ==================== CONTENT ==================== -->
<div class="overview">
<?php the_content(); ?>
<?php the_post_thumbnail('full'); ?>
</div>
<!-- ==================== CONTENT ==================== -->
</div><!-- / .viewport -->
</div><!-- / .Scrollbar1 -->
<?php endif; ?>
<!-- End If Portfolio-->
<?php echo '</div></div>';
}
?>
<!-- End foreach -->
</div>
<!-- / #content-inner -->
<?php for( $i=1; $i<=($numposts); $i++ )
{
echo '</div>';
} ?>
<?php get_footer(); ?>
Thanks!
Please see the documentation! Get the image with:
get_the_post_thumbnail($pag->ID, 'full');
Documentation for the_post_thumbnail($size, $attr);
This tag must be used within The Loop. Use get_the_post_thumbnail($id,
$size, $attr ) instead to get the featured image for any post.
http://codex.wordpress.org/Function_Reference/the_post_thumbnail
here is my blog page template:
<?php
/**
* Template Name: Blog
*
* Standard blog template, create a static page for your blog and select this as the template.
*
* The "Template Name:" bit above allows this to be selectable
* from a dropdown menu on the edit page screen.
*/
get_header(); ?>
<div id="main_container">
<!-- IE7 float fix --><!--[if lt IE 7]><span class="iefix">.</span><![endif]-->
<div class="main">
<div class="entries_full">
<div class="entry_full">
<div class="box_twothirds mt30 pr60">
<!-- BLOG POSTS BEGIN -->
<?php
$exclude_cat = get_option('bb_exclude_cat');
$exclude_temp = str_replace(",", ",-", $exclude_cat);
$exclude_cats = "-" . $exclude_temp;
$blog_posts = get_option('bb_blog_posts');
if($blog_posts == NULL) {$blog_posts = '5';}
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query('cat=' . $exclude_cats . '&paged=' . $paged . '&showposts=' . $blog_posts);
$count = 0;
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<div class="blog">
<!-- displays the blog posts -->
<?php $count++; if($count > 3) { $count = 1; } ?>
<h3 class="<?php if($count > 1) echo "mt25 "; ?>mb12"><?php the_title(); ?></h3>
<?php if(get_post_meta($post->ID, large_image_value, $single = true) != NULL || get_post_meta($post->ID, fullsize_value, $single = true) != NULL)
{ ?>
<div class="mag_blog"><!-- magnifying glass div -->
<img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php if (get_post_meta($post->ID, large_image_value, true) != NULL) {echo get_post_meta($post->ID, large_image_value, $single = true);} else if (get_post_meta($post->ID, fullsize_value, true) != NULL) {echo get_post_meta($post->ID, fullsize_value, $single = true);} else {echo get_post_meta($post->ID, accordion_image_value, true);} ?>&h=213&w=600&zc=1" alt="<?php the_title(); ?>" />
</div><!-- end magnifying glass div -->
<?php } ?>
<p class="meta"><span class="postdate"><?php the_time('F jS, Y') ?></span><span class="tags"><?php the_category(', '); ?></span><span class="comments"><?php comments_number('0 comments','1 comment','% comments'); ?></span></p>
<?php global $more; $more = false; ?><?php the_content('<span>Continue Reading</span>'); ?><?php $more = true; ?>
<div class="bar mt25 mb30"></div>
<?php comments_template( '', true ); ?>
</div>
<?php endwhile;
if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<?php next_posts_link( __( '← Older posts', 'twentyten' ) ); ?>
<?php previous_posts_link( __( 'Newer posts →', 'twentyten' ) ); ?>
<?php endif; ?>
<?php }
$wp_query = null; $wp_query = $temp; ?>
<!-- BLOG POSTS END -->
</div>
<!-- Begin Sidebar -->
<?php include('sidebar.php'); ?>
<!-- end sidebar -->
<div class="clear"></div>
</div><!-- end div.entry -->
</div><!-- end div.entries -->
<div class="clear"></div>
</div><!-- end div#main -->
<div class="clear"></div>
</div><!-- end div#main_container-->
<?php get_footer(); ?>
</code>
Just wonder if there is a way to add a class to the first blog item, or a way to make the first block item has different style than the rest... Or I need to edit on other php file?
Thanks guys.
You can do exactly that within the first line of your while() loop:
Replace:
<div class="blog">
With:
<div class="blog<?php if ($count === 0) echo " first_post"; ?>">
That should add a custom class to the first blog item on the page called 'first_post'.