Skip to content

Instantly share code, notes, and snippets.

<?php
add_action( 'init', 'my_theme_custom_post' );
function my_theme_custom_post() {
register_post_type( 'agent',
array(
'labels' => array(
'name' => __( 'Agents' ),
@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 / 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 / google-fonts.php
Last active November 11, 2022 10:22
How to call google fonts from theme option in best way
<?php
$frozen_body_font_get = cs_get_option('frozen_body_font');
$frozen_heading_font_get = cs_get_option('frozen_headding_font');
function frozen_crazycafe_body_gf_url() {
$font_url = '';
$frozen_body_font_get = cs_get_option('frozen_body_font');
if(array_key_exists('family', $frozen_body_font_get)) {
$frozen_body_font_get_family = $frozen_body_font_get['family'];
@raselahmed7
raselahmed7 / custom-post-loop-with-pagination-shortcode.php
Last active September 7, 2022 16:23
Custom post loop with pagination in shortcode
<?php
function portfolios_shortcode($atts){
extract( shortcode_atts( array(
'expand' => '',
), $atts) );
global $paged;
$posts_per_page = 6;
$settings = array(
@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
function stock_styled_map_shortcode($atts, $content = null) {
extract( shortcode_atts( array(
'lat' => '40.7433379',
'lng' => '-74.0103219',
'title' => 'Head Office',
'desc' => 'House 21, Grand St.<br/> New York, USA',
@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');
}
});
function woocommerce_cart_link() {
global $woocommerce;
?>
<a href="<?php echo esc_url($woocommerce->cart->get_cart_url()); ?>" title="<?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> <?php _e('in your shopping cart', 'woothemes'); ?>" class="cart-button ">
<span class="label"><?php esc_html_e('My Basket:', 'woothemes'); ?></span>
<?php echo esc_html($woocommerce->cart->get_cart_total()); ?>
<span class="items"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count); ?></span>
</a>
<?php
}
@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; ?>