Skip to content

Instantly share code, notes, and snippets.

View mohsinr's full-sized avatar

Mohsin Rasool mohsinr

View GitHub Profile
@mohsinr
mohsinr / wp-functions.php
Last active December 19, 2018 12:34
WordPress Common Custom Codes for Functions.php
<?php
//* Add new image sizes
add_image_size( 'logo-thumb', 270, 180, TRUE );
//* Change the number of portfolio items to be displayed (props Bill Erickson)
add_action( 'pre_get_posts', 'minimum_portfolio_items' );
function minimum_portfolio_items( $query ) {
if ( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
$query->set( 'posts_per_page', '6' );
@mohsinr
mohsinr / functions.php
Created October 29, 2015 10:41
Convert Hex Color to RGBa to create Color Shades on the fly
<?php
/* Convert hexdec color string to rgb(a) string */
function hex2rgba($color, $opacity = false) {
$default = 'rgb(0,0,0)';
//Return default if no color provided
if(empty($color))
return $default;
@mohsinr
mohsinr / functions.php
Created October 29, 2015 10:24
Add Excerpts Support for WordPress Pages
<?php
// Add Post Excerpt Support to WordPress Pages
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
add_post_type_support( 'page', 'excerpt' );
}
@mohsinr
mohsinr / .htaccess
Last active September 11, 2015 06:55
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/