Skip to content

Instantly share code, notes, and snippets.

@krishna19
krishna19 / standard.php
Created October 3, 2016 10:04
standard.php
<?php
$show_thumb = get_post_meta(get_the_ID(), 'aq_format_0', TRUE);
$thumb = wp_get_attachment_url( get_post_thumbnail_id(),'full');
$image = aq_resize( $thumb, 1000, 400, true );
?>
<?php if ($show_thumb != 'no' && has_post_thumbnail() ) : ?>
<div class="post_image">
<img src="<?php echo $image; ?>" alt="">
@krishna19
krishna19 / generate_options_css.php
Created October 3, 2016 10:02 — forked from syamilmj/generate_options_css.php
generate_options_css()
function generate_options_css($newdata) {
/** Define some vars **/
$data = $newdata;
$uploads = wp_upload_dir();
$css_dir = get_template_directory() . '/css/'; // Shorten code, save 1 call
/** Save on different directory if on multisite **/
if(is_multisite()) {
$aq_uploads_dir = trailingslashit($uploads['basedir']);
/*
* Load More for Masonry modification
*
* Full post:
* http://www.billerickson.net/infinite-scroll-in-wordpress/
*
*/
jQuery(function($){
// simple smooth scrolling for bootstrap scroll spy nav
// credit http://stackoverflow.com/questions/14804941/how-to-add-smooth-scrolling-to-bootstraps-scroll-spy-function
$(".navbar-nav li a[href^='#']").on('click', function(e) {
// prevent default anchor click behavior
e.preventDefault();
// store hash
var hash = this.hash;
@krishna19
krishna19 / WordPress - Import Menu Item's custom fields.php
Created January 14, 2016 17:06 — forked from mo3aser/WordPress - Import Menu Item's custom fields.php
How to modify the WordPress importer plugin to Import Menu Item's custom fields
<?php
# WordPress - Import Menu Item's custom fields
# By Fouad Badawy - TieLabs.com
#1- Edit wordpress-importer.php
#2 search for
$id = wp_update_nav_menu_item( $menu_id, 0, $args );
if ( $id && ! is_wp_error( $id ) )
$this->processed_menu_items[intval($item['post_id'])] = (int) $id;
@krishna19
krishna19 / php-html-css-js-minifier.php
Created January 4, 2016 17:15 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
@krishna19
krishna19 / jquery.icontains.js
Created December 27, 2015 02:00 — forked from pklauzinski/jquery.icontains.js
Custom jQuery :icontains selector for finding element based on text in a page, case-insensitive
/**
* Example use:
* $('div:icontains("Text in page")');
* Will return jQuery object containing any/all of the following:
* <div>text in page</div>
* <div>TEXT in PAGE</div>
* <div>Text in page</div>
*/
$.expr[':'].icontains = $.expr.createPseudo(function(text) {
return function(e) {
@krishna19
krishna19 / custom-taxonomy-post-loop.php
Created November 22, 2015 05:31
Loop through sutom taxomonies and display posts
<?php
//this loop returns all movies separated by genres they belong to
$post_type = 'brand';
$tax = 'division';
$tax_terms = get_terms($tax);
if ($tax_terms) {
foreach ($tax_terms as $tax_term) {
$args=array(
@krishna19
krishna19 / wp-list-tags.php
Created November 22, 2015 05:30
list all tags and show current
<ul class="accordian-content">
<?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
$isCurrent = ((int) $tag->term_id === get_queried_object_id()) ? 'class="current"' : '';
echo '<li' . $isCurrent .'><a href="' . get_tag_link( $tag->term_id ) . '">' . $tag->name.'</a> </li>';
@krishna19
krishna19 / snippet-next-prev-post-links.php
Created November 22, 2015 05:30
get previous/next post links
<?php
/**
* Infinite next and previous post looping in WordPress
*/
$next_post = get_next_post();
$previous_post = get_previous_post();
$current_id = get_the_ID();
// Get ID's of posts