Skip to content

Instantly share code, notes, and snippets.

View sarvar's full-sized avatar

Sarvar sarvar

  • Uzbekistan, Tashkent
View GitHub Profile
@sarvar
sarvar / wp-trim-words-example.php
Created November 21, 2016 11:07
Wp trim words
<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 / dynamic_bg.php
Created November 27, 2016 07:28
How to customize a divs background dynamically using Advanced Custom Fields
<div <?php if ( get_field('field_name') ) { echo 'style="background-image: url(' . get_field('field_name') . ')"'; } ?> class="hero container">
<h2>I Need a Hero</h2>
<p>I'm holding out for a hero 'til the end of the night</p>
</div>
source: http://www.endocreative.com/how-to-empower-clients-to-easily-customize-background-images/
@sarvar
sarvar / style.css
Created November 27, 2016 17:11
Wordpress ACF field into a stylesheet
html, body {background-color:<?php the_field('page_background_color', 'option' );?>;}
@sarvar
sarvar / zipper.php
Created November 30, 2016 09:18
unzip files via FTP
<?php
/* Simple script to upload a zip file to the webserver and have it unzipped
Saves tons of time, think only of uploading Wordpress to the server
Thanks to c.bavota (www.bavotasan.com)
I have modified the script a little to make it more convenient
Modified by: Johan van de Merwe (12.02.2013)
*/
function rmdir_recursive($dir) {
foreach(scandir($dir) as $file) {
@sarvar
sarvar / loop.php
Created December 1, 2016 00:27
Display one specific page in loop
<?php $my_query = new WP_Query('page_id=87');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<div class="entry">
<?php the_content('read more &raquo;'); ?>
</div>
@sarvar
sarvar / carousel.php
Created December 1, 2016 18:25
Bootstrap Carousel with Multiple Images using ACF Gallery & Fancybox
@sarvar
sarvar / woocommerce.php
Created December 3, 2016 17:07
Hide sub-category product count in product archives woocommerce
add_filter( 'woocommerce_subcategory_count_html', 'jk_hide_category_count' );
function jk_hide_category_count() {
// No count
}
@sarvar
sarvar / proxy.txt
Created December 6, 2016 19:44
Reset git proxy to default configuration
git config --global --unset http.proxy
git config --global -l
@sarvar
sarvar / npm.txt
Created December 11, 2016 07:19
Upgrade Node.js via NPM
npm install npm@latest -g
@sarvar
sarvar / path.txt
Created December 29, 2016 06:39
image path in wordpress
<img src="<?php echo get_bloginfo( 'template_directory' ); ?>/images/morebutton.png" />