Skip to content

Instantly share code, notes, and snippets.

View dcooney's full-sized avatar

Darren Cooney dcooney

View GitHub Profile
@dcooney
dcooney / gist:ae4caec3f9061dd47627
Last active September 9, 2017 01:00
Query by Category Ajax Load More
<?php
$cat = get_query_var('cat');
$category = get_category ($cat);
echo do_shortcode('[ajax_load_more seo="true" category="'.$category->slug.'"]');
?>
@dcooney
dcooney / gist:4d07ff95f7274f38fd3a
Created May 30, 2014 19:21
Query by Author ID
<?php
$author = get_the_author_meta('ID');
echo do_shortcode('[ajax_load_more author="'.$author.'"]');
?>
@dcooney
dcooney / gist:fc4276bebbdd05af64d1
Last active August 29, 2015 14:02
Query by Tag
<?php
$tag = get_query_var('tag');
echo do_shortcode('[ajax_load_more tag="'.$tag.'"]');
?>
@dcooney
dcooney / gist:cca35c2b20e0deb30811
Last active August 29, 2015 14:02
Pause Loading Shortcode
<?php echo do_shortcode('[ajax_load_more repeater="repeater2" posts_per_page="1" scroll="false" pause="true" transition="fade" button_label="Load Posts"]');?>
@dcooney
dcooney / gist:f08a27480c1c45870764
Last active August 29, 2015 14:03
Fade Transition
<?php echo do_shortcode(['[ajax_load_more post_type="ajax_more" posts_per_page="2" transition="fade" button_label="Load More Posts"]']) ?>
@dcooney
dcooney / gist:aa46ebec0e4ae1f83b42
Last active August 29, 2015 14:04
Get Page ID by slug
<?php
function get_page_id($page_name){
global $wpdb;
$page_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$page_name."'");
return $page_id;
}
@dcooney
dcooney / gist:d796dc0644bbcaaf4fab
Last active August 29, 2015 14:04
Multiple Instances
<?php echo do_shortcode('[ajax_load_more post_type="ajax_more" posts_per_page="1" scroll="false" transition="fade" button_label="Load More Posts"]'); ?>
<hr/>
<?php echo do_shortcode('[ajax_load_more post_type="portfolio" posts_per_page="1" scroll="false" transition="fade" button_label="Load More Work"]'); ?>
<?php echo ('[ajax_load_more]'); ?>
@dcooney
dcooney / gist:b5eb55a2f88214accfb9
Created September 13, 2014 12:58
Change Preview Featured Image Size in WordPress
/**********************************************
* Update featured image size in editor
*********************************************/
add_filter( 'admin_post_thumbnail_html', 'cnkt_add_featured_instructions');
function cnkt_add_featured_instructions( $content ) {
$content .= '<p><em>The featured image should be at least 972px × 244px.</em></p>'; // Append to $content
$content = str_replace(__('Set featured image'), __('Add Header Image'), $content);
$content = str_replace('-70x70', '', $content); // Remove thumbnail image dimensions
$content = str_replace('width="70"', '', $content); // Remove width attr
@dcooney
dcooney / gist:7f95ab73f6c5c5c4605b
Created September 20, 2014 16:07
Custom post type columns with custom fields
// Add custom columns to milsstones post type
function my_milestone_columns($columns){
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'year' => 'Year',
'month' => 'Month',
'date' => 'Date',
);
return $columns;