Skip to content

Instantly share code, notes, and snippets.

@mjinayan80
mjinayan80 / custom-post-query
Last active October 25, 2017 07:14
custom-post
<?php
global $post;
$args = array( 'posts_per_page' => 10, 'post_type'=> 'custom-post-type' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<?php
$job_link= get_post_meta($post->ID, 'job_instructions', true);
?>
@mjinayan80
mjinayan80 / isotope-active.js
Created October 25, 2017 07:21
jQuery isotope filter
jQuery(document).ready(function($){
$(".all-portfolios").isotope({
itemSelector: '.single-portfolio',
layoutMode: 'fitRows',
});
$('ul.filter li').click(function(){
$("ul.filter li").removeClass("active");
$(this).addClass("active");
@mjinayan80
mjinayan80 / related-posts.php
Created October 25, 2017 07:30
related-posts.php
@mjinayan80
mjinayan80 / autop in shortcode.php
Created October 25, 2017 07:32
autop in shortcode.php
<?php
$my_autop_content = get_the_content();
'.wpautop( $my_autop_content ).'
?>
@mjinayan80
mjinayan80 / PHP if else test
Created October 25, 2017 07:33
PHP if else test
<?php
// Provide an example of an "if – elseif - else" control structure that tests if $day is ‘Monday.’ If so, display ‘Today is Monday.’ Repeat the test of each weekday, displaying ‘Today is (name of the week day),’ otherwise display “It is the weekend.”
$dayname = 'Monday';
if($dayname = 'Monday') :
echo 'Today is Monday.';
elseif() :
echo 'Today is ';
@mjinayan80
mjinayan80 / homepage-only
Created October 25, 2017 07:35
Homepage only look wordpress
<?php if( is_home() || is_front_page() ) : ?>
<!-- Homepage Only Code -->
<?php else : ?>
<!-- Other Page Code -->
<?php endif; ?>
@mjinayan80
mjinayan80 / jquery-sticky-menu.js
Created October 25, 2017 07:37
jQuery sticky menu
// Sticky Header
$(window).scroll(function() {
if ($(window).scrollTop() > 100) {
$('.main_h').addClass('sticky');
} else {
$('.main_h').removeClass('sticky');
}
});
@mjinayan80
mjinayan80 / enable-masonry.php
Created October 25, 2017 07:39
Enable masonry form wordpress
add_action( 'wp_enqueue_scripts', 'jk_masonry' );
function jk_masonry() {
wp_enqueue_script( 'jquery-masonry', array( 'jquery' ) );
}
/*
How to use?
$('#container').masonry({ singleMode: true });
@mjinayan80
mjinayan80 / wordpress-image-crop.php
Created October 25, 2017 07:41
Wordpress image crop
<?php
// in functions.php
add_theme_support( 'post-thumbnails');
/*
Wordpress crop an image = 5 size. Sizes are given below
thumbnail // Thumbnail (default 150px x 150px max)
@mjinayan80
mjinayan80 / cart-functions-filter.php
Created October 25, 2017 09:49
cart-functions-filter.php
function header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
woocommerce_cart_link();
$fragments['a.cart-button'] = ob_get_clean();
return $fragments;