Skip to content

Instantly share code, notes, and snippets.

View sarvar's full-sized avatar

Sarvar sarvar

  • Uzbekistan, Tashkent
View GitHub Profile
@sarvar
sarvar / gist:dddd450a1a04200ff6c10089aa36228b
Created April 12, 2016 17:05
CSS3 Media Queries Template
/*
* Author: http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries/
*/
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
<?php query_posts('page=28'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php echo get_field( 'sale_images_url', $page->ID ); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<img src="<?php echo get_field('book_cover_thumbnail');?>" />
<?php end while; endif; ?>
@sarvar
sarvar / multiple_loops.php
Created April 15, 2016 05:47
Multiple Loops Worpdress
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<!-- do stuff ... -->
<?php endwhile; ?>
<?php endif; ?>
@sarvar
sarvar / loadmore.php
Created April 19, 2016 08:15
ajax load more function in wordpress
--------sample.php--------------
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="eventBody itemBody">
<?php query_posts('post_type=events&posts_per_page=3'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
@sarvar
sarvar / code.php
Created May 1, 2016 16:04
Useful wp-php-code
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
*************
<?php
if ( is_front_page() && is_home() ) : ?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php endif;
@sarvar
sarvar / post-carousel.php
Created May 8, 2016 06:17
Wordpress post horizontal carousel
<!-- Carousel -->
<div id="newsCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
// Item size (set here the number of posts for each group)
$i = 3;
// Set the arguments for the query
global $post;
$args = array(
@sarvar
sarvar / category-image.php
Created May 12, 2016 18:49
Dislay category image in wordpress
<ul class="styleUl categoryList">
<?php
$args = array('child_of' => 31);
$categories = get_categories( $args );
foreach($categories as $cat) {
echo '<li class="col-lg-4 col-md-4 col-sm-6 col-xs-12">';
echo '<a class="catImg infoImg" href="' . get_category_link($cat->term_id) . '">';
echo '<span class="over_view"></span>';
echo '<span class="imgHover">';
echo '<i class="fa fa-chevron-right" aria-hidden="true"></i>';
@sarvar
sarvar / shortcode.php
Created June 16, 2016 16:03
Using shortcode in php
<?php echo do_shortcode("[example_shortcode]"); ?>
@sarvar
sarvar / title.php
Created June 17, 2016 05:46
Use wp_trim_words() to limit words in WordPress
<div class="info-box">
<?php $krogsquery = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 3
)); ?>
<h3 class="info-headline">City News</h3>
<?php while($krogsquery->have_posts()) : $krogsquery->the_post(); ?>
@sarvar
sarvar / navbar.css
Created July 1, 2016 03:50
Change Navbar breakpoint in Bootstrap
@media (max-width: 768px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;