Skip to content

Instantly share code, notes, and snippets.

View josephhinson's full-sized avatar

Joseph Hinson josephhinson

View GitHub Profile
@josephhinson
josephhinson / triangleFold.less
Created November 18, 2013 17:46
CSS Folding triangle from corner of any element
.triangleFold(@size, @basebackground, @foldcolor) {
&:after {
content: '';
width: 0;
height: 0;
border-left: @size solid transparent;
border-right: 0px solid transparent;
border-bottom: @size solid @basebackground;
position: absolute;
bottom: 0px;
@josephhinson
josephhinson / searchfilter.php
Last active December 28, 2015 10:29
Search Filter (to return results by post type). Create a custom search form where you can set a hidden input to search that specific post type...see below the PHP block.
<?php
function otg_optional_search_filter($query) {
$post_type = $_GET['type'];
if (!$post_type) {
$post_type = 'any';
}
if ($query->is_search) {
$query->set('post_type', $post_type);
};
return $query;
@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(
@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 / 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 / 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.