I have a situation trying to implement into the <header>, a logotext using kerning technique, desk cross-browsers compatible.
Beginning with this simple but very handy tool made by Mr.Andrew (special thanks), I have found a solution.
Before the modification, I had this <header> section in header.php:
...
<!-- Start Header -->
<header class="header row no-padding <?php echo $header_style; ?>" data-equal=">.columns" role="banner">
<div class="small-7 medium-4 columns logo<?php if ($header_style == 'style1') { ?> show-for-large-up<?php } ?>">
<?php if ($header_style == 'style2') { ?>
<a class="logotext" href="<?php echo esc_url( home_url( '/' ) ); ?>"
title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"
rel="home"><?php bloginfo( 'name' ); ?>
</a>
<?php } ?>
</div>
<?php if ($header_style != 'style2') { ?>
<div class="small-7 medium-4 columns logo">
<?php if ($header_style == 'style1') { ?>
<a class="logotext" href="<?php echo esc_url( home_url( '/' ) ); ?>"
title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"
rel="home"><?php bloginfo( 'name' ); ?>
</a>
<?php } ?>
</div>
<?php } ?>
<div class="small-5 <?php if ($header_style == 'style2') { echo 'medium-8'; } else { echo 'medium-4';} ?> columns menu-holder">
<?php $full_menu_true = ($menu_mobile_toggle_view == 'style2' && $header_style == 'style2');?>
<?php if ($full_menu_true) { ?>
<nav id="full-menu" role="navigation">
<?php if ($page_menu) { ?>
<?php wp_nav_menu( array( 'menu' => $page_menu, 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown ) ); ?>
<?php } else if(has_nav_menu('nav-menu')) { ?>
<?php wp_nav_menu( array( 'theme_location' => 'nav-menu', 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown ) ); ?>
<?php } else { ?>
<ul class="full-menu">
<li>Please assign a menu from Appearance -> Menus</li>
</ul>
<?php } ?>
</nav>
<?php } ?>
<?php if ($header_search != 'off') { do_action( 'thb_quick_search' ); } ?>
<?php if ($header_cart != 'off') { do_action( 'thb_quick_cart' ); } ?>
<a href="#" data-target="open-menu" class="mobile-toggle<?php if (!$full_menu_true) { ?> always<?php } ?>">
<div>
<span></span><span></span><span></span>
</div>
</a>
</div>
</header>
<!-- End Header -->
...
After:
...
<!-- Start Header -->
<header class="header row no-padding <?php echo $header_style; ?>" data-equal=">.columns" role="banner">
<div class="row max_width ">
<div class="small-7 medium-4 columns logo<?php if ($header_style == 'style1') { ?> show-for-large-up<?php } ?>">
<?php if ($header_style == 'style2') { ?>
<div class="small-7 medium-4 columns logo">
<span class="logotext-n">n</span>
<span class="logotext-e">e</span>
<span class="logotext-u">u</span>
<span class="logotext-e2">e</span>
<span class="logotext-g">g</span>
<span class="logotext-r">r</span>
<span class="logotext-i">i</span>
<span class="logotext-d">d</span>
</div>
<?php } ?>
</div>
</div>
<?php if ($header_style != 'style2') { ?>
<div class="row max_width ">
<div class="small-7 medium-4 columns logo">
<?php if ($header_style == 'style1') { ?>
<div class="small-7 medium-4 columns logo">
<span class="logotext-n">n</span>
<span class="logotext-e">e</span>
<span class="logotext-u">u</span>
<span class="logotext-e2">e</span>
<span class="logotext-g">g</span>
<span class="logotext-r">r</span>
<span class="logotext-i">i</span>
<span class="logotext-d">d</span>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<div class="row max_width ">
<div class="small-5 <?php if ($header_style == 'style2') { echo 'medium-8'; } else { echo 'medium-4';} ?> columns menu-holder">
<?php $full_menu_true = ($menu_mobile_toggle_view == 'style2' && $header_style == 'style2');?>
<?php if ($full_menu_true) { ?>
<nav id="full-menu" role="navigation">
<?php if ($page_menu) { ?>
<?php wp_nav_menu( array( 'menu' => $page_menu, 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown ) ); ?>
<?php } else if(has_nav_menu('nav-menu')) { ?>
<?php wp_nav_menu( array( 'theme_location' => 'nav-menu', 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown ) ); ?>
<?php } else { ?>
<ul class="full-menu">
<li>Please assign a menu from Appearance -> Menus</li>
</ul>
<?php } ?>
</nav>
<?php } ?>
<?php if ($header_search != 'off') { do_action( 'thb_quick_search' ); } ?>
<?php if ($header_cart != 'off') { do_action( 'thb_quick_cart' ); } ?>
<a href="#" data-target="open-menu" class="mobile-toggle<?php if (!$full_menu_true) { ?> always<?php } ?>">
<div>
<span></span><span></span><span></span>
</div>
</a>
</div>
</div>
</header>
<!-- End Header -->
...
the css code:
...
.logotext-n {
color: #f1ecd6;
font-family: "arial black", sans-serif;
font-weight: 900;
font-size: 210px;
text-transform: lowercase;
letter-spacing: -29px;
}
.
.
.
.logotext-d {
color: #f1ecd6;
font-family: "arial black", sans-serif;
font-weight: 900;
font-size: 210px;
text-transform: lowercase;
letter-spacing: 0;
}
...
At this point I've found that kerning values looks different in IE/Firefox vs. Chrome. I've read about the Media Query and I've tried this for Chrome values display correction:
...
#media screen and (-webkit-min-device-pixel-ratio:0) {
.logotext-n {
color: #f1ecd6;
font-family: "arial black", sans-serif;
font-weight: 900;
font-size: 210px;
text-transform: lowercase;
letter-spacing: -18px;
}
}
.
.
.
#media screen and (-webkit-min-device-pixel-ratio:0) {
.logotext-d {
color: #f1ecd6;
font-family: "arial black", sans-serif;
font-weight: 900;
font-size: 210px;
text-transform: lowercase;
letter-spacing: 0;
}
}
...
The result looks as it should in every browser IE11/Firefox38.0.5/Chrome43.0.2357.124 m, Also I dont have any error in the Chrome console, nevertheless:
Being a noob in coding stuff, is this a good kerning technique for cross browser support or is there any other alternative to apply the Media Query or other conditions in a direct / short way? Thank you,
There's a CSS font-kerning property. No need to separate your logo-text into an element for each letter.
If you need custom kerning, you can make all your letter spans have position: relative and use CSS to move them left or right.
Related
I'm trying to change the header logo on my site, depending on the page the person is on. I don't know PHP, but I've found where the Logo is defined in header.php, and am trying to rewrite it to be dynamic. When I use my code, the site breaks, so obviously I'm doing something wrong.
Here is the code of my header.php file.
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head><meta charset="<?php bloginfo( 'charset' ); ?>">
<!-- Set the viewport width to device width for mobile -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.css" integrity="sha256-0LjJurLJoa1jcHaRwMDnX2EQ8VpgpUMFT/4i+TEtLyc=" crossorigin="anonymous" />
<?php
wp_head();
?>
<style>
.chosen-container .chosen-results {
height: 100%;
overflow-y: hidden;
max-height: inherit;
}
.chosen-container-active .chosen-single, .chosen-container-single .chosen-single {
display: none;
}
.chosen-container-single .chosen-drop {
display: contents;
}
</style>
</head>
<body <?php body_class(); ?>>
<div class="<?php $themnific_redux = get_option( 'themnific_redux' );
if (empty($themnific_redux['tmnf-uppercase'])) {} else {if($themnific_redux['tmnf-uppercase'] == '1') echo 'upper '; }
if (empty($themnific_redux['tmnf-bottombar-dis'])) {} else {if($themnific_redux['tmnf-bottombar-dis'] == '1') echo 'bottombar_dis '; }
if ( is_active_sidebar( 'tmnf-sidebar' ) ) {echo 'tmnf-sidebar-active ';} else { echo 'postbarNone ';};
if (empty($themnific_redux['tmnf-header-layout'])) {} else {echo esc_attr($themnific_redux['tmnf-header-layout']);}
?>">
<div id="header" class="tranz" itemscope itemtype="http://schema.org/WPHeader">
<div class="container_head">
<a class="screen-reader-text ribbon skip-link" href="#content_start"><?php esc_html_e('Skip to content','citygov');?></a>
<div class="clearfix"></div>
<div id="titles" class="tranz2">
<?php if(empty($themnific_redux['tmnf-main-logo']['url'])) { ?>
<h1 class="logo"><?php bloginfo('name');?></h1>
<?php }
else { ?>
<a class="logo" href="<?php echo esc_url(home_url('/')); ?>">
<img class="tranz" src="<?php echo esc_url($themnific_redux['tmnf-main-logo']['url']);?>" alt="<?php bloginfo('name'); ?>"/>
</a>
<?php } ?>
</div><!-- end #titles -->
<div class="header-right for-menu">
<input type="checkbox" id="showmenu" aria-label="<?php esc_html_e('Open Menu','citygov');?>">
<label for="showmenu" class="show-menu ribbon" tabindex="0"><i class="fas fa-bars"></i> <span><?php esc_html_e('Menu','citygov');?></span></label>
<nav id="navigation" class="rad tranz" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation" aria-label="<?php esc_html_e( 'Main Menu', 'citygov' ); ?>">
<?php get_template_part('/includes/navigation'); ?>
</nav>
</div><!-- end .header-right -->
<div class="clearfix"></div>
<div id="bottombar" class="bottomnav tranz" role="navigation" aria-label="<?php esc_html_e( 'Quick Links', 'citygov' ); ?>">
<?php if(empty($themnific_redux['tmnf-menu-label'])) {} else { ?>
<p class="menu_label"><?php echo esc_attr($themnific_redux['tmnf-menu-label']); ?></p>
<?php }?>
<div class="header-right">
<?php get_template_part('/includes/add-navigation'); ?>
<?php get_template_part('/includes/uni-social' );?>
</div>
</div><!-- end #bottombar -->
<div class="clearfix"></div>
</div><!-- end .container -->
</div><!-- end #header -->
<?php ?>
<div class="wrapper p-border">
You can do this by simply put below code in your theme's functions.php file.
after putting this code, you can now see the new settings added into back-end admin area.
Go to the wordpress admin area then go to Appearance > Customize > Site Identity.
You can now see there are two new settings.
1)Upload Logo (replaces text) => You can add second logo for other pages
2) Page IDs. => You can add comma separated page ids in this text box for displaying second logo in that pages.
function jay_customize_register( $wp_customize ) {
$wp_customize->add_setting( 'jay_logo' );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'jay_logo', array(
'label' => __( 'Upload Logo (replaces text)', 'jay' ),
'section' => 'title_tagline',
'settings' => 'jay_logo',
) ) );
$wp_customize->add_setting('page_ids');
$wp_customize->add_control('text_setting', array(
'label' => 'Page IDs',
'section' => 'title_tagline',
'type' => 'text',
'settings' => 'page_ids',
));
}
add_action( 'customize_register', 'jay_customize_register' );
function change_logo_on_single($html) {
$pageIDs = (get_theme_mod('page_ids'))? explode(',',get_theme_mod('page_ids')) : array();
if(in_array(get_the_ID(),$pageIDs)){
$html = preg_replace('/<img(.*?)\/>/', '<img src="'.get_theme_mod('jay_logo').'" class="custom-logo" alt="" itemprop="logo" />', $html);
}
return $html;
}
add_filter('get_custom_logo','change_logo_on_single');
I want popular-excerpt to be margin-bottom:20px however it won't work. I've tried doing both margin-bottom and padding-bottom but neither of them work.
Here is my code
a.popular-excerpt {
text-decoration: none;
color: #000000;
margin-bottom: 20px;
}
<div id="slider">
<?php
$carousel_cat = get_theme_mod('carousel_setting','1');
$carousel_count = get_theme_mod('count_setting','4');
$month = date('m');
$year = date('Y');
$new_query = new WP_Query( array('posts_per_page' => $carousel_count, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC','monthnum'=>$month,'year'=>$year ));
?>
<?php if ( $new_query->have_posts() ) : ?>
<?php while ( $new_query->have_posts() ) : $new_query->the_post(); ?>
<div class="item">
<?php the_post_thumbnail('popular-posts'); ?>
<h2><a class="popular-category"
<?php
$categories = get_the_category();
$separator = ", ";
$output = '';
if ($categories) {
foreach ($categories as $category) {
$output .= '' . $category->cat_name . '' . $separator;
}
echo trim($output, $separator);
}
?></a></h2>
<p>
<a class="popular-excerpt" href="<?php the_permalink(); ?>"><?php echo get_the_excerpt(); ?></a>
</p>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Sorry, No Popular Posts Found ' ); ?></p>
<?php endif; ?>
</div>
Your <a> element is an inline element and top and bottom margins do not affect inline elements. You should set its display to block or inline-block.
a.popular-excerpt {
text-decoration: none;
color: #000000;
margin-bottom: 20px;
display:block;
}
I have this problem creating a navigation that reacts with my get_posts($args). Have tried everything, and all I can find on the web is solutions done with wp query.
I use ACF and Bootstrap, so I would really like to stick with get_posts.
The code beneath here is my current code, that works perfectly to only show 5 post. But how do I create a navigation for the pagination?
<div class="articles">
<?php
$args = array( //'numberposts' => -1
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 5,
'paged' => $paged,);
$posts= get_posts( $args );
if ( $posts ) :
$counter = 1;
foreach ( $posts as $p ) :
$classCount = 'post-'.$counter;
if( $classCount == 'post-1' ) : echo '<div class="mediumPost col-xs-12 col-sm-6 col-md-6 col-lg-6">';
elseif( $classCount == 'post-2' || $classCount == 'post-3' ) : echo '<div class="smallPost col-xs-12 col-sm-6 col-md-6 col-lg-6">';
elseif( $classCount == 'post-4' ) : echo '<div class="largePost col-xs-12 col-sm-12 col-md-12 col-lg-12">';
elseif( $classCount == 'post-5' ) : echo '<div class="mediumPost col-xs-12 col-sm-6 col-md-6 col-lg-6">';
elseif( $classCount == 'post-6' || $classCount == 'post-7' ) : echo '<div class="smallPost col-xs-12 col-sm-6 col-md-6 col-lg-6">';
else : echo '<div class="smallPost col-xs-12 col-sm-6 col-md-6 col-lg-6">';
endif; ?>
<?php $postImg = get_field('post_image', $p->ID ); if( !empty($postImg) ): ?>
<img src="<?php echo $postImg['url']; ?>" alt="<?php if(!empty($postImg['alt'])): echo $postImg['alt']; else : echo the_title(); endif; ?>" />
<?php endif; ?>
<div class="iconBox">
<?php $getIcon = get_field('post_type', $p->ID); ?>
<?php $catIcon = get_field($getIcon, 132); ?>
<?php if( !empty($catIcon) ): ?>
<img class="iconImg" src="<?php echo $catIcon['url']; ?>" alt="<?php if(!empty($catIcon['alt'])): echo $catIcon['alt']; else : echo the_title(); endif; ?>" />
<?php endif; ?>
</div>
<?php $categories = get_the_category($p->ID);
$category_id = $categories[0]->cat_ID; ?>
<?php if( $category_id == 9 ) : ?>
<h4 data-toggle="modal" data-target="#myModal-<?php echo $counter ?>"><?php echo get_the_title( $p->ID ); ?></h4>
<span class="articles-btn" data-toggle="modal" data-target="#myModal-<?php echo $counter ?>">Watch link</span>
<!-- Modal -->
<div class="modal fade" id="myModal-<?php echo $counter ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h5 class="modal-title" id="myModalLabel"><?php echo get_the_title( $p->ID ); ?></h5>
</div>
<div class="modal-body">
<div class="embed-container">
<?php // get iframe HTML
$iframe = get_field('post_embed', $p->ID);
// use preg_match to find iframe src
preg_match('/src="(.+?)"/', $iframe, $matches);
$src = $matches[1];
// add extra params to iframe src
$params = array(
'controls' => 1,
'hd' => 1,
'autohide' => 1
);
$new_src = add_query_arg($params, $src);
$iframe = str_replace($src, $new_src, $iframe);
// add extra attributes to iframe html
$attributes = 'frameborder="0"';
$iframe = str_replace('></iframe>', ' ' . $attributes . '></iframe>', $iframe); ?>
<?php echo $iframe; ?>
</div>
</div>
</div>
</div>
</div>
<?php else : ?>
<h4><?php echo get_the_title( $p->ID ); ?></h4>
<span class="articles-btn">READ MORE</span>
<?php endif; ?>
</div> <!--postSize div-->
<?php $counter++; if ( 11 === $counter ) $counter = 1; endforeach; wp_reset_postdata();?>
<?php endif; ?>
</div>
Copy this function in your functions.php
function custom_pagination($numpages = '', $pagerange = '', $paged='') {
if (empty($pagerange)) {
$pagerange = 2;
}
/**
* This first part of our function is a fallback
* for custom pagination inside a regular loop that
* uses the global $paged and global $wp_query variables.
*
* It's good because we can now override default pagination
* in our theme, and use this function in default queries
* and custom queries.
*/
global $paged;
if (empty($paged)) {
$paged = 1;
}
if ($numpages == '') {
global $wp_query;
$numpages = $wp_query->max_num_pages;
if(!$numpages) {
$numpages = 1;
}
}
/**
* We construct the pagination arguments to enter into our paginate_links
* function.
*/
$pagination_args = array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'total' => $numpages,
'current' => $paged,
'show_all' => False,
'end_size' => 1,
'mid_size' => $pagerange,
'prev_next' => True,
'prev_text' => __('«'),
'next_text' => __('»'),
'type' => 'plain',
'add_args' => false,
'add_fragment' => ''
);
$paginate_links = paginate_links($pagination_args);
if ($paginate_links) {
echo "<nav class='custom-pagination'>";
echo "<span class='page-numbers page-num'>Page " . $paged . " of " . $numpages . "</span> ";
echo $paginate_links;
echo "</nav>";
}
}
Put this in your css
.custom-pagination span,
.custom-pagination a {
display: inline-block;
padding: 2px 10px;
}
.custom-pagination a {
background-color: #ebebeb;
color: #ff3c50;
}
.custom-pagination a:hover {
background-color: #ff3c50;
color: #fff;
}
.custom-pagination span.page-num {
margin-right: 10px;
padding: 0;
}
.custom-pagination span.dots {
padding: 0;
color: gainsboro;
}
.custom-pagination span.current {
background-color: #ff3c50;
color: #fff;
}
Put this above your arguments list in get_posts()
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
after the loop of get posts at the bottom paste this
<?php
if (function_exists(custom_pagination)) {
custom_pagination(count($posts) ,"",$paged);
}
?>
i have a problem with search result page, the pagination doesn't works, when i want to go to next page, i'm redirected to index page, but the url is: www.mywebsite.com/page/2/?s=word..
For all pages the pagination works, only for search doesn't works.
this is the code of search.php
<?php
/**
* The template for displaying Search Results pages.
*/
get_header(); ?>
<?php
$search = isset( $_GET['s'] ) ? $_GET['s']: null;
$user_filtre = '';
$user_display = '';
if( $search ){
$user_filtre .= 's=' . $_GET['s'] . '&';
$user_display .= 's=' . $_GET['s'] . '&';
}?>
<div id="main-search" class="content-dark hidden-sm hidden-xs">
<div class="container">
<form method="get" action="<?php bloginfo('url'); ?>" accept-charset="UTF-8">
<!--input name="s" id="s" type="hidden" -->
<div id="main-search-fields">
<p class="pull-left term">Search Term:</p>
<input name="s" value="<?php the_search_query(); ?>"autocomplete="off" type="search">
</div>
<div id="main-search-btn">
<input class="button-green-download-big" type="submit" value="Search">
</div>
</form>
</div>
</div>
<div class="browse-content">
<div class="container">
<section>
<div class="row">
<ul>
<?php if(have_posts() ): ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php include '_includes/items/item_2.php';?>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
</section>
<?php novavideo_theme_pagination(); ?>
</div>
</div>
</div>
Anyone have an ideea?
item_2.php.
<div class="browse-movie-wrap col-xs-10 col-sm-4 col-md-5 col-lg-4">
<a href="<?php the_permalink(); ?>" class="browse-movie-link">
<figure>
<?php if($values = get_post_custom_values("poster_url")) { ?>
<img class="img-responsive" src="<?php echo $values[0]; ?>" alt="<?php the_title();?> Watch Online" width="210" height="315">
<?php } ?>
<figcaption class="hidden-xs hidden-sm">
<span class="fa fa-star icon-color"></span>
<h4 class="rating"><?php $rating = get_post_custom_values("imdbRating"); echo $rating[0]; ?> / 10</h4>
<h4>
<?php $categories = get_the_category();
if ( ! empty( $categories[0] ) ) {
echo esc_html( $categories[0]->name );
}
?>
</h4>
<h4 class="quality-button"><span class="fa fa-play-circle"></span> <?php $terms_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, 'quality', '', ', ', '' ) ); echo $terms_as_text;; ?></h4>
<span class="button-green-download-big margin-button">Open Movie</span>
</figcaption>
</figure>
</a>
<div class="browse-movie-bottom">
<?php $title = get_post_custom_values("Title"); echo $title[0]; ?>
<div class="browse-movie-year"><?php $terms = wp_get_post_terms($post->ID, 'release-year', array("fields" => "all")); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ foreach ( $terms as $term_single ) { $term_link = get_term_link( $term_single ); echo $term_single->name; } } ?></div>
</div>
</div>
Search results are instantiated through query_posts and that controls how many results you have per page. In your code, it's probably happening via the include: /_includes/search-template.php but if not, set it up like this:
// 1- Created a paged variable that knows how many paginated pages exist (depends on your site)
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
// 2- Pass `paged` into array of arguments for query_posts
$args = array(
'posts_per_page' => 20,
'order' => 'DESC',
'paged' => $paged,
);
// 3- Submit query_posts to WordPress with arguments set
query_posts( $args );
Now you can use next_posts_link(); to show the paginated page link. Just replace the references to theme_pagination(); with next_post_link(); and it should output the right results.
If you want to abstract all this logic out of your template, check out pre_get_posts. It's a different method and you would put all this logic into functions.php but will achieve similar results.
This is my code for Search result page with pagination:
<?php get_header(); ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/search.css">
<?php wp_head(); ?>
<script type="text/javascript">
var window_width = window.screen.width;
var window_height = window.screen.height;
<?php $window_width = "<script>document.write(window_width)</script>";
$window_height = "<script>document.write(window_height)</script>"; ?>
</script>
<style>
.sm_bd{padding: 5px;
border: 1px solid
#ccc;}
.row {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
flex-wrap: wrap;
}
.row > [class*='col-'] {
display: flex;
flex-direction: column;
}
.previous,.next {
padding: 5px;
border: 1px solid
#ccc;
border-radius: 4px;
margin: 15px;
}
</style>
</head>
<body class="index-body">
<?php include 'menu.php';?>
<div class="col-xs-12 col-sm-12 blog-page no-marg no-padd">
<div class="col-xs-4 col-sm-3 single-sidebar no-marg no-padd">
My sidebar
</div>
<section id="primary" class="content-area col-xs-12 col-sm-12 col-lg-8 col-md-8">
<div id="content" class="site-content row" role="main">
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : '1';
$s=get_search_query();
$args = array(
's' =>$s,
'paged' => $paged,
'posts_per_page' => '12',
);
// The Query
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
_e("<h2 style='font-weight:bold;color:#000'>نتایج جستجو برای: ".get_query_var('s')."</h2>");
echo "<div class='col-lg-12 col-md-12'><hr/></div>";
while ( $the_query->have_posts() ) {
$the_query->the_post();
?>
<div class="col-xs-12 col-sm-12 col-lg-3 col-md-3 sm_bd">
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php else : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<img class="attachment-post-thumbnail size-post-thumbnail wp-post-image lazyloaded" src="Without Image"
alt="<?php the_title_attribute(); ?>"
title="<?php the_title_attribute(); ?>" width="300" height="449">
</a>
<?php endif;?>
<?php the_title(); ?>
</div>
<?php
}
?>
<div class="pagination" id="blog-pagination">
<?php if( get_previous_posts_link('← ', $loop->max_num_pages ) ) : ?>
<span class="previous" ><?php previous_posts_link( '→ ', $loop->max_num_pages ); ?></span>
<?php endif; ?>
<?php if( get_next_posts_link('← ', $loop->max_num_pages ) ) : ?>
<span class="next"><?php next_posts_link( '←', $loop->max_num_pages ); ?></span>
<?php endif; ?>
</div>
<?php
}
else{
?>
<h2 style='font-weight:bold;color:#000'>not found title</h2>
<div class="alert alert-info">
<p>not found alert</p>
</div>
<?php }
wp_reset_postdata();?>
</div><!-- #content .site-content -->
</section><!-- #primary .content-area -->
</div>
<?php get_footer(); ?>
don't forget to write wp_reset_postdata(); after post loop.
Has anyone been able to implement Twitter Bootstrap carousel with keyboard controls? I know this is going to be implement in the next release, but for now I was wondering if any of you has been able to make it work.
Here's my current code:
<script type="text/javascript">
jQuery(document).keypress(function(event) {
if (event.keyCode === RIGHT_ARROW) {
$('a.carousel-control.right').trigger('click');
}
if (event.keyCode === LEFT_ARROW) {
$('a.carousel-control.left').trigger('click');
}
});
</script>
But I'm not getting anywhere with this. Any ideas?
Edit: Here's the Wordpress code I am running...
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
<?php if ( $post->post_type == 'portfolios' && $post->post_status == 'publish' ) {
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'exclude' => get_post_thumbnail_id(),
'orderby' => 'menu_order',
'order' => 'ASC'
) );
?>
<?php if ( $attachments ) {
$the_rest = array_slice($attachments, 0, 100);
?>
<div id="carousel-<?php the_ID(); ?>" class="featured-carousel carousel slide carousel-fade">
<div class="carousel-inner">
<?php
global $post;
$post_num = 0;
foreach( $the_rest as $attachment) :
$image = wp_get_attachment_image_src( $attachment->ID, 'orion-thumb-900', false );
$post_num++;
?>
<div class="item <?php if($post_num == 1){ echo 'active'; } ?>">
<?php echo "<img src='" . $image[0] . "'>"; ?>
<div class="container">
</div> <!-- /.container -->
</div> <!-- /.item -->
<?php endforeach; ?>
<?php } ?>
<?php } ?>
</div> <!-- /.carousel-inner -->
<a class="left carousel-control" href="#carousel-<?php the_ID(); ?>" data-slide="prev">‹</a>
<a class="right carousel-control" href="#carousel-<?php the_ID(); ?>" data-slide="next">›</a>
</div> <!-- /.carousel -->
<section class="entry-content clearfix">
<?php the_content(); ?>
<?php orion_related_posts(); ?>
</section> <!-- end article section -->
</article> <!-- end article -->
<?php endwhile; ?>
thanks for that,
Even better with carousel events and devices support - 'click' sucks these days!
$(document).bind('keyup', function(e) {
if(e.which == 39){
$('.carousel').carousel('next');
}
else if(e.which == 37){
$('.carousel').carousel('prev');
}
});
Here's the correct code, thanks DavidChase and Flemingslone!
<script type="text/javascript">
jQuery(document).bind('keyup', function(e) {
if (e.keyCode==39) {
jQuery('a.carousel-control.right').trigger('click');
}
else if(e.keyCode==37){
jQuery('a.carousel-control.left').trigger('click');
}
});
</script>