Skip to content

Instantly share code, notes, and snippets.

View anwerashif's full-sized avatar
🚩
Coding

Anwer Ashif anwerashif

🚩
Coding
View GitHub Profile
@anwerashif
anwerashif / functions.php
Last active October 28, 2017 16:49
Customize Genesis Site Footer Text
<?php
//Don't include PHP tag
// Customize the footer section
add_filter('genesis_footer_creds_text', 'bdfg_footer_creds_text');
function bdfg_footer_creds_text($creds) {
global $wpdb;
$table = $wpdb->prefix . 'posts';
$lastDate = date('Y');
$firstDate = $wpdb->get_var("SELECT YEAR(post_date) FROM $table ORDER BY post_date LIMIT 1");
@anwerashif
anwerashif / disableoption.js
Created October 28, 2017 17:07
jQuery - Disable Selected Option at Ninja Form
jQuery(window).load(function() {
jQuery("#ninja_forms_widget-2 select option:selected").attr('disabled','disabled')
.siblings().removeAttr('disabled');
});
@anwerashif
anwerashif / archive-code.php
Created October 28, 2017 17:49
Archive Template for Custom Post Type in Genesis
<?php
// Do NOT include the opening PHP tag
/**
* Template Name: Code Snippets Archive
* Description: Used as a page template to show custom-post-type 'code'
*/
// Add 'code_snippet' ID
function be_site_inner_attr( $attributes ) {
@anwerashif
anwerashif / functions.php
Created October 28, 2017 18:03
Register 'custom' post type to WordPress
<?php
// Do NOT include the opening PHP tag
/**
* Register `code` post type
*/
function code_post_type() {
// Labels
$labels = array(
@anwerashif
anwerashif / functions.php
Last active October 28, 2017 19:52
Register Custom Featured Image Size for Page in Genesis
<?php
// Do NOT include the opening PHP tag
// Register a custom image size for Singular Page Featured images
add_image_size( 'singular-page-featured-thumb', 1277, 300, true );
// Display image before content-sidebar-wrap
add_action( 'genesis_before_content_sidebar_wrap', 'page_display_featured_image' );
function page_display_featured_image() {
if ( ! is_singular( array( 'page' ) ) ) {
@anwerashif
anwerashif / readme.txt
Last active October 30, 2017 17:15
Remove Empty Lines and Spaces in Notepad++
To get rid of leading space(s) and all empty lines (even if the empty line contains spaces or tabs)
# Go to Search -> Replace
# Select "Regular expression" under Search mode.
# Use ^\s* for "Find what" and leave "Replace with" blank.
# Click Replace all
Regex explanation:
# ^ means beginning of the line
# \s* means any number (even 0) of whitespace characters. Whitespace characters include tab, space, newline, and carriage return.
@anwerashif
anwerashif / style.css
Created October 30, 2017 18:09
Add a Background-Image and CSS3 Gradient on the Same Element
#hero-img {
background: #3B5998;
background: -moz-linear-gradient(to right, #3b5a9b 0%,#5387f4 100%);
background: -webkit-linear-gradient(to right, #3b5a9b 0%,#5387f4 100%);
background: url(svg/pattern-right.svg), linear-gradient(to right, #3b5a9b 0%,#5387f4 100%);
background-position: left center,center center;
background-repeat: no-repeat,no-repeat;
background-size: 675px 600px, cover;
}
@anwerashif
anwerashif / functions.php
Last active October 31, 2017 21:35
Add Featured Image to Single Post and Page in Genesis
<?php
// Do NOT include the opening PHP tag
// Register a custom image size for Singular Post and Page Featured images
add_image_size( 'singular-featured-thumb', 880, 450, true ); // Hard Crop Mode
// Display featured image above content
add_action( 'genesis_before_entry', 'display_featured_image' );
function display_featured_image() {
if ( ! is_singular( array( 'post', 'page' ) ) ) {
@anwerashif
anwerashif / functions.php
Created November 1, 2017 22:12
Unregister Default Layouts Except sidebar-content and full-width in Genesis
<?php
// Do NOT include the opening PHP tag
// Unregister default layouts
genesis_unregister_layout( 'content-sidebar' );
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
@anwerashif
anwerashif / functions.php
Last active November 3, 2017 18:26
Add custom logo
<?php
// Do NOT include the opening PHP tag
// Add custom logo or Enable option in Customizer > Site Identity
add_theme_support( 'custom-logo', array(
'width' => 244,
'height' => 315,
'flex-width' => true,
'flex-height' => true,
'header-text' => array( '.site-title', '.site-description' ),