Skip to content

Instantly share code, notes, and snippets.

<?php
$count = 1;
$wp_query= null;
$args=array(
'taxonomy' => 'course-category', // taxonomy slug
'post_status' => 'publish',
'posts_per_page' => 2
);
$wp_query = new WP_Query($args);
while ($wp_query->have_posts()) : $wp_query->the_post();
@sproutventure
sproutventure / IE browser class updated.
Created October 29, 2010 18:27
IE browser body class
// Checks userAgent and adds body classes for IE
jQuery(document).ready(function() {
if (jQuery.browser.msie) {
jQuery('body').addClass('ie');
jQuery('body').addClass('ie' + $.browser.version.substring(0, 1));
}
});
<?php
/*
Template Name: Loop template
*/
get_header();
?>
<div id="loop" class="grid_8 alpha clearfix">
<div id="content">
@sproutventure
sproutventure / GBS Theme Homepage Loop
Created September 29, 2010 23:39
GBS Theme Homepage Loop
<?php
$count = 1;
$deal_query= null;
$args=array(
'post_type' => 'deal',
'post_status' => 'publish',
'posts_per_page' => '3' // Change the total you want to return here
);
$deal_query = new WP_Query($args);
while ($deal_query->have_posts()) : $deal_query->the_post(); // Start building the content
<?php //if ( !is_home() || !is_front_page() ): ?>
<div id="sub-form-wrap" class="grid_4 omega clearfix">
<div id="sub-form" class="clearfix">
<?php group_buying_subscription_form() ?>
</div><!-- // #sub-form.clearfix -->
</div>
<?php //endif ?>
# Delete duplicate comments
// Creates a temp table of IDs to compare later
CREATE TEMPORARY TABLE unique_comments SELECT MAX(c1.comment_ID) as ID FROM wp_comments c1 GROUP BY c1.comment_content ORDER BY ID;
// If the comment ID isn't in the unique table delete it
DELETE FROM wp_comments WHERE comment_ID NOT IN (SELECT ID FROM unique_comments);
function custom_taxes()
{
// Taxonomies
$universe_labels = array(
'name' => _x( 'Nexus', 'taxonomy general name' ),
'singular_name' => _x( 'Affiliate', 'taxonomy singular name' ),
'search_items' => __( 'Search Affiliations' ),
'all_items' => __( 'All Affiliates' ),
'parent_item' => __( 'Parent Affiliate' ),
'parent_item_colon' => __( 'Parent Affiliate:' ),
/**
* Creates a nexus term on publish
*
* @param string $id
* @param string $post
* @return void
* @author Dan Cameron
*/
function autoadd_nexus_category($id, $post) {
if( $post->post_status == 'publish' && false === (wp_is_post_autosave($post) || wp_is_post_revision($post) )
function is_old_post($post_id=null){
$days = 15;
global $wp_query;
if(is_single() || is_page()) {
if(!$post_id) {
$post_id = $wp_query->post->ID;
}
$current_date = time();
$offset = $days *60*60*24;
$post_id = get_post($post_id);
if ( ! $this->args['labels'] ) {
$default_labels = array (
'name' => _x(ucwords($post_type)),
'singular_name' => _x($post_type),
'add_new' => _x('Add New'),
'add_new_item' => sprintf(__('Add New %s'), $post_type),
'edit_item' => sprintf(__('Edit %s'), $post_type),
'new_item' => sprintf(__('New %s'), $post_type),
'view_item' => sprintf(__('View %s'), $post_type),
'search_items' => sprintf(__('Search New %s'), ucwords($post_type)),