Skip to content

Instantly share code, notes, and snippets.

@raselahmed7
raselahmed7 / wordpress-dummy-code
Last active November 22, 2016 14:34
Wordpress dummy codes
<?php the_title(); ?>
function theme_latest_jquery() {
wp_enqueue_script('jquery');
}
add_action('init', 'theme_latest_jquery');
@raselahmed7
raselahmed7 / wordpress-image-crop.php
Last active February 1, 2023 05:56
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)
@raselahmed7
raselahmed7 / enable-masonry.php
Last active August 29, 2015 14:06
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 });
@raselahmed7
raselahmed7 / jquery-sticky-menu.js
Created September 21, 2014 06:44
jQuery sticky menu
// Sticky Header
$(window).scroll(function() {
if ($(window).scrollTop() > 100) {
$('.main_h').addClass('sticky');
} else {
$('.main_h').removeClass('sticky');
}
});
@raselahmed7
raselahmed7 / custom-post-query
Created September 23, 2014 02:19
Custom post query with custom field wordpress
<?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);
?>
@raselahmed7
raselahmed7 / homepage-only
Created September 23, 2014 13:16
Homepage only look wordpress
<?php if( is_home() || is_front_page() ) : ?>
<!-- Homepage Only Code -->
<?php else : ?>
<!-- Other Page Code -->
<?php endif; ?>
@raselahmed7
raselahmed7 / wordpress-cheat-sheet
Created September 24, 2014 06:22
Wordpress cheatsheets
<?php wp_nav_menu( array( 'theme_location' => 'wpj-main-menu', 'menu_id' => 'nav' ) ); ?>
<?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 ';
@raselahmed7
raselahmed7 / isotope-active.js
Created January 5, 2015 17:36
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");
<?php
$my_autop_content = get_the_content();
'.wpautop( $my_autop_content ).'
?>