Skip to content

Instantly share code, notes, and snippets.

View josephhinson's full-sized avatar

Joseph Hinson josephhinson

View GitHub Profile
@josephhinson
josephhinson / login_wl_memberlevels
Created May 20, 2015 20:03
Wishlist Member Levels and Login Form
<?php ?>
<div class="member-login">
<?php if (is_user_logged_in()):
$loggedin = true;
$user = wp_get_current_user();
$levels = WLMAPI::GetUserLevels($user->ID);
$getlevels = WLMAPI::GetLevels();
endif; ?>
<a class="button" href="javascript:void(null);" onclick="jQuery('.dropdown-box').toggle();">
<?php if ($loggedin): ?>
@josephhinson
josephhinson / responsive_embed
Created July 10, 2015 14:16
Make WordPress video embedding responsive
<?php
// add these lines to your functions file
add_filter( 'embed_oembed_html', 'embed_responsively_oembed_filter', 10, 4 ) ;
// the following function will wrap the embedded code in a responsive frame, where the video is 100% width
function embed_responsively_oembed_filter($html, $url, $attr, $post_ID) {
$return = "<style>
.embed-container {
position: relative;
<?php
function my_login_logo() {
// this will add a block fo css to the page that you can customize on the login page.
?>
<style type="text/css">
body.login div#login h1 a {
background-image: url(<?php echo get_bloginfo( 'stylesheet_directory' ) ?>/images/login_logo.png);
padding-bottom: 3px;
background-size: contain;
width: 100%;
@josephhinson
josephhinson / dump_tags_and_categories.php
Created August 4, 2015 15:14
Quick dump of all tags and categories into a table with their name, slug, and count (in descending order of count)
<?php
$args = array(
'orderby' => 'count',
'order' => 'DESC',
'hide_empty' => true,
'exclude' => array(),
'exclude_tree' => array(),
'include' => array(),
'number' => '',
'fields' => 'all',
@josephhinson
josephhinson / return_season.php
Last active September 15, 2015 15:59
Return the current season based on day
<?php
function return_season() {
$day = date('z');
if( $day < 79) $season = 'winter';
elseif( $day < 171) $season = 'spring';
elseif( $day < 265) $season = 'summer';
elseif( $day < 354) $season = 'fall';
else $season = "winter";
return $season;
@josephhinson
josephhinson / remote_folder_rewrite
Last active September 18, 2015 01:25
serve wp-uploads from production in dev htaccess
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^tempurl.com$
RewriteRule ^(.+)$ http://siteurl.com/wp-content/uploads/$1 [L,R=301,NE]
@josephhinson
josephhinson / WordPress Permalink Override
Created May 28, 2013 17:33
This snippet overrides the WordPress permalink with a custom field called "post_URL" if that custom field exists.
@josephhinson
josephhinson / Pull content from any page given the slug, WordPress shortcode
Last active December 17, 2015 20:59
So, you want to pull content from one page into another...maybe you have an "upcoming events" section that you want to be its own page, yet you also want to show on another page. This shortcode will help you do that. Put this code in your functions.php file.
<?php
// [page name="contact"]
function page_content($atts) {
extract(shortcode_atts(array(
'name' => ''
), $atts));
$return = '';
$args=array(
'name' => $name,
'post_type' => 'page',
@josephhinson
josephhinson / new_read_more.php
Created October 30, 2013 14:43
[WordPress] When you want to add "Read More" to all excerpts, regardless of length
<?php
// Excerpt Filter this will remove any text added to the excerpt
function new_excerpt_more($more) {
global $post;
return '';
}
// This will append the excerpt with additional text, "Read More"
function the_excerpt_always_show_read_more($content) {
global $post;
@josephhinson
josephhinson / taxonomy-archive.php
Created November 5, 2013 13:55
Taxonomy archive page for some reason, WordPress doesn't seem to like the taxonomy archive by default, so I usually end up creating this page, it's a bit of a hack, but it works. Name it taxonomy-your_taxonomy.php -- obviously edit as needed, but the code should work universally...
<?php get_header(); ?>
<div class="container blog content">
<div class="row">
<div class="span8 entry">
<div class="headline">
<?php
$value = get_query_var($wp_query->query_vars['taxonomy']);
$cat = get_term_by('slug',$value,$wp_query->query_vars['taxonomy']); ?>
<h1><?php echo $cat->name; ?></h1>
<?php $loop = new WP_Query(array(