Skip to content

Instantly share code, notes, and snippets.

View markbain's full-sized avatar
๐ŸŽฏ
Focusing

Mark Bain markbain

๐ŸŽฏ
Focusing
View GitHub Profile
@markbain
markbain / archive-meta-sort.php
Created November 9, 2018 16:16
Order archive by meta #wordpress
/**
* Order person achive results A-Z by last name
*/
function baindesign324_reorder_posts_person( $query ) {
if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'cpt1' ) {
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'last_name');
$query->set('order', 'ASC');
}
}
@markbain
markbain / archive-title.php
Created November 9, 2018 15:14
Archive title based on theme_mod #wordpress #theme_mod #customizer
<?php
if ( get_theme_mod( 'baindesign324_work_archive_title', '' ) ) {
echo get_theme_mod( 'baindesign324_work_archive_title', '' );
} else {
echo post_type_archive_title();
}
@markbain
markbain / Language switcher
Created November 9, 2018 15:11
Language switcher
<?php // Language Switcher
// Uses WPML plugin
if ( class_exists( 'SitePress' ) && function_exists( 'baindesign324_languages_list' ) ) {
echo '<div id="switcher">';
baindesign324_languages_list();
echo '</div>';
}
?>
@markbain
markbain / filter algolia
Created October 30, 2018 16:21
Algolia filter for images
// Algolia filters
add_filter('algolia_post_images_sizes', function($sizes) {
$sizes[] = 'latest_post';
return $sizes;
});
@markbain
markbain / shortcuts_aliases.md
Last active December 7, 2021 22:57
Shortcuts and aliases #shortcuts #aliases
  • gaa git add --all (sames as -A)
  • gcam "my commit message" git commit -a -m
  • ggp git push origin $(current_branch)
  • gco {master} git checkout
  • gpoat git push origin --all && git push origin --tags
  • gst git status
  • gb git branch
@markbain
markbain / buttons.html
Last active September 19, 2018 08:33
Custom button classes
<h3>Basic button</h3>
<p><a class="button" href="#" style="font-size: 16px;">Click me</a></p>
<p><a class="button" href="#" style="font-size: 18px;">Click me</a></p>
<p><a class="button" href="#" style="font-size: 20px;">Click me</a></p>
<h3>Special offer!</h3>
<p><a class="button button__icon button__special" href="#" style="font-size: 16px;">Special offer!</a></p>
<p><a class="button button__icon button__special" href="#" style="font-size: 18px;">Special offer!</a></p>
<p><a class="button button__icon button__special" href="#" style="font-size: 20px;">Special offer!</a></p>
@markbain
markbain / tarcommands.md
Last active November 30, 2018 16:16 — forked from anonymous/tarcommands.md
tar commands

tar --exclude='wp-content/uploads/backupbuddy_backups' --exclude='wp-content/uploads/backwpup-4a2f83-backups' --exclude='wp-content/uploads/backupbuddy_temp' --exclude='wp-content/uploads/2018/09' --exclude='wp-content/uploads/2018/08' --exclude='wp-content/uploads/2018/07' --exclude='wp-content/uploads/2018/06' --exclude='wp-content/uploads/2018/05' --exclude='wp-content/uploads/2018/04' --exclude='wp-content/uploads/2018/03' --exclude='wp-content/uploads/2018/02' --exclude='wp-content/uploads/2018/01' --exclude='wp-content/uploads/2017' --exclude='wp-content/uploads/2016' --exclude='wp-content/uploads/2015' --exclude='wp-content/uploads/2014' --exclude='wp-content/uploads/2013' --exclude='wp-content/uploads/2012' -zcvf wp-content-prod.tar.gz wp-content

@markbain
markbain / one_off_script.php
Created November 8, 2016 14:55
How to run a one-time WordPress script
http://exygy.com/run-one-time-wordpress-script/
<?php
$dir = dirname(__FILE__);
echo "<p>Full path to this dir: " . $dir . "</p>";
echo "<p>Full path to a .htpasswd file in this dir: " . $dir . "/.htpasswd" . "</p>";
?>
@markbain
markbain / .gitignore
Last active August 29, 2015 14:24
My sample .gitignore
# =========================
# Various
# =========================
node_modules
bower_components
.sass-cache
import
export
scripts