Skip to content

Instantly share code, notes, and snippets.

View sachyya's full-sized avatar
🏠
Working from home

sachyya sachyya

🏠
Working from home
View GitHub Profile
FTP credentials on plugin installation:
define( 'FS_METHOD', 'direct' );
Pretty permalinks not working:
Edit /etc/apache2/apache2.conf and change:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
su
adduser username sudo
Then reboot.
<?php
/**
* Collects all the default theme mods value in an array
* @return array All the default theme mods values
*/
function prefix_get_theme_mods_defaults() {
$defaults = array(
// Site footer options
'option1' => 'value1',
'option2' => 'value2',
@sachyya
sachyya / custom_wp_is_mobile.php
Created November 24, 2015 07:42
This gist is to use WordPress inbuilt function wp_is_mobile excluding the ipad view port
function custom_wp_is_mobile() {
static $is_mobile;
if ( isset($is_mobile) )
return $is_mobile;
if ( empty($_SERVER['HTTP_USER_AGENT']) ) {
$is_mobile = false;
} elseif (
strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false
@sachyya
sachyya / loop posts by year
Created October 29, 2015 11:13
This gist is to loop the posts in a specific year in a chunk by year.
//create two custom functions
<?php //retrive years that have posts
function st_get_years_having_posts( $post_type ) {
// get years that have posts
global $wpdb;
$date_query = "SELECT YEAR(post_date) AS year FROM {$wpdb->prefix}posts WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY year DESC";
$years = $wpdb->get_results( $date_query );
return $years;
}