Skip to content

Instantly share code, notes, and snippets.

View sarvar's full-sized avatar

Sarvar sarvar

  • Uzbekistan, Tashkent
View GitHub Profile
@sarvar
sarvar / Wordpress ACF
Last active December 14, 2015 20:05
acf, getting thumbnail size image from field
<?php $image = get_sub_field('NAMEOFYOURSUBIMAGEFIELD'); ?>
<?php if( $image ): ?>
<img src="<?php echo $image['sizes']['YOURCUSTOMSIZE']; ?>" width="<?php echo $image['sizes']['YOURCUSTOMSIZE-width']; ?>" height="<?php echo $image['sizes']['YOURCUSTOMSIZE-height']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
@sarvar
sarvar / link.php
Created December 14, 2015 20:13
Link to External URLs?
@sarvar
sarvar / hide_field.php
Created December 14, 2015 20:57
Hiding empty fields ACF
<?php if( get_field('field_name') ): ?>
<p>My field value: <?php the_field('field_name'); ?></p>
<?php endif; ?>
@sarvar
sarvar / thumnail-size.php
Last active December 20, 2015 21:25
Thumnail Size Wordpress
width="<?php echo $image['sizes']['medium-width']; ?>" height="<?php echo $image['sizes']['medium-height']; ?>"
<?php the_post_thumbnail('thumbnail'); ?>
the_post_thumbnail(); // without parameter -> Thumbnail
the_post_thumbnail('thumbnail'); // Thumbnail
the_post_thumbnail('medium'); // Medium resolution
the_post_thumbnail('large'); // Large resolution
@sarvar
sarvar / thumbnail-bg.php
Created December 23, 2015 17:15
Use post thumbnail as div background
<?php if ( have_posts() ) : query_posts('p=64');
while ( have_posts() ) : the_post(); ?>
<?php
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), false, '' );
?>
<? endwhile; endif; wp_reset_query(); ?>
@sarvar
sarvar / sort-posts.php
Created December 25, 2015 21:51
Sort Posts (or Pages) by title
<?php
/*
Plugin Name: Set Post Order In Admin
Version: 0.1
Plugin URI: http://wordpress.org/support/topic/336715/
Description: In Posts->Edit, display posts in title order.
Author: MichaelH
Author URI: http://codex.wordpress.org/User:MichaelH/MyPlugins
*/
@sarvar
sarvar / attachment-img.php
Created December 28, 2015 00:11
Get attachment image
<?php query_posts('category_name=Portfolio&order=ASC&orderby=date&posts_per_page=36'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
$url = $thumb['0'];
?>
<li><a style="background-image:url(<?=$url?>);" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"></a></li>
@sarvar
sarvar / vertically-align-txt.html
Created January 7, 2016 05:17
Vertically Align text in a Div
<div style="display: table; height: 400px; overflow: hidden;">
<div style="display: table-cell; vertical-align: middle;">
<div>
everything is vertically centered in modern IE8+ and others.
</div>
</div>
</div>
@sarvar
sarvar / jquery-page-preload.js
Created January 17, 2016 17:21
jQuery Page Preload
#loader {
background: none repeat scroll 0 0 #ffffff;
bottom: 0;
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;
z-index: 9999;
@sarvar
sarvar / no-animate.css
Created February 27, 2016 12:36
Turn OFF Animate.css on Mobile Devices
/* Small Devices, Tablets */
@media only screen and (max-width : 768px) {
.animated {
/*CSS transitions*/
-o-transition-property: none !important;
-moz-transition-property: none !important;
-ms-transition-property: none !important;
-webkit-transition-property: none !important;
transition-property: none !important;
/*CSS transforms*/