Skip to content

Instantly share code, notes, and snippets.

@cameronbaney
cameronbaney / add-new-post.php
Created February 7, 2014 18:06
Add a new post to WordPress from outside the dashboard with PHP
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "update_form") {
$membername = $_POST['membername'];
if($_POST['title']){
$post_title = $_POST['title'];
} else {
$post_title = 'update';
}
// ADD THE FORM INPUT TO $new_post ARRAY
@cameronbaney
cameronbaney / fullscreen-video-bg.js
Created January 30, 2014 15:51
Fullscreen scaling background video
var $video = $('.bg-video');
//// Videos
function setProportion(video) {
var proportion = getProportion(video);
video.width(proportion*1920);
video.height(proportion*1080);
centerVideo(video);
}
@cameronbaney
cameronbaney / loading-icon.css
Created August 8, 2013 17:12
Spinning icon (used for animation)
/* Vendor prefixes have not yet been added */
.icon-loading {
font-size: 56px;
left: 50%;
margin: -23px 0 0 -23px;
position: fixed;
top: 50%;
z-index: 9999;
text-shadow: 0 2px 1px rgba(0,0,0,.6);
@cameronbaney
cameronbaney / gist:5832963
Created June 21, 2013 17:48
Link Filezilla sitemanager files across a network
ln -s /Volumes/Corporate/ME_Web/FTP/sitemanager.xml ~/.filezilla/sitemanager.xml
@cameronbaney
cameronbaney / custom-dashboard-columns
Created June 17, 2013 15:07
List meta keys in the dashboard of custom post types
// Add custom column to the Papers area
add_filter('manage_edit-[POST-TYPE]_columns', 'custom_papers_cols');
function custom_papers_cols($gallery_columns) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['id'] = __('ID');
$new_columns['title'] = _x('Title', 'column name');
$new_columns['papertype'] = __('Paper Type');
$new_columns['author'] = __('University');
@cameronbaney
cameronbaney / Custom.css
Last active December 18, 2015 11:39 — forked from carlosasin/Custom.css
/*
Cobalt theme by Carlos Asín
************************************
A cobalt theme for Chrome Developer Tools inspired by Sublime Text 2 cobalt theme.
Modifies the source code and other smaller tweaks.
@cameronbaney
cameronbaney / wp_query
Created June 6, 2013 15:48
Basic WordPress Custom Query
<?php
$custom = new WP_Query(array('post_type'=>'block','posts_per_page'=>'4','orderby'=>'menu_order','order'=>'ASC'));
while ( $custom->have_posts() ) : $custom->the_post(); ?>
<? // THE LOOP ?>
<?php
endwhile;
wp_reset_postdata();
?>
@cameronbaney
cameronbaney / gist:5006522
Last active December 14, 2015 01:29
SQL to migrate WordPress site
UPDATE wp_options SET option_value = 'http://www.newsite.com' WHERE option_name IN ('siteurl', 'home')
UPDATE wp_posts SET post_content=(REPLACE (post_content, '{old url}','{new url}'))
@cameronbaney
cameronbaney / gist:4665651
Last active December 11, 2015 21:58
Create A Filter Based On Query Strings For Relationships
<?php
//***********************************************************/
// CREATE A FILTER BASED ON QUERY STRINGS FOR RELATIONSHIPS //
// URL FOR THIS EXAMPLE: /?practice_area=92,88&lawyer=69 //
//***********************************************************/
// Get the query string for practice areas
$pas = explode(',', $_GET['practice_area']);
$lawyers = explode(',', $_GET['lawyer']);
<?php
$relcases = new WP_Query(array('post_type'=>'verdicts','posts_per_page'=>'3',
'meta_query'=>array(
array(
'key' => 'rel_practice_area',
'value' => "$pID",
'compare' => 'LIKE'
)
))
); ?>