Skip to content

Instantly share code, notes, and snippets.

View celticwebdesign's full-sized avatar

Darren Stevens celticwebdesign

View GitHub Profile
@celticwebdesign
celticwebdesign / Bootstrap pagination function
Created May 24, 2016 09:36
Bootstrap pagination function
<?php
// http://fellowtuts.com/wordpress/bootstrap-3-pagination-in-wordpress/
if (function_exists("wp_bs_pagination"))
{
//wp_bs_pagination($the_query->max_num_pages);
wp_bs_pagination();
}
?>
@celticwebdesign
celticwebdesign / WordPress push loop results in to array of objects
Created May 29, 2016 09:40
WordPress push loop results in to array of objects - based on meta field date
<?php
$args = array(
'post_type' => 'special-offers-cpt',
'post_status' => 'publish',
'posts_per_page' => -1
);
// The query
$child_query = new WP_Query($args);
$('a#footer-icon').click(function(e) {
e.preventDefault();
var $t = $('#footer .bottom');
if ($t.is(':visible')) {
$t.slideUp(400);
} else {
$t.slideDown(400);
$("html, body").animate({ scrollTop: $(document).height() }, 1000);
HCV
HTML - add data-attribute(clicked-node) to each photo with counter.
jQuery
// PhotoSwipe
$(".grid-item img").click(function(e) {
e = e || window.event;
e.preventDefault ? e.preventDefault() : e.returnValue = false;
<?php
// If needed to get a specific category
// echo "<pre>";
// var_dump($wp_query->query_vars);
// echo "</pre>";
// echo $wp_query->query_vars['gallery-category'];
$args = array(
'post_type' => 'gallery',
<section class="wrapper full taxonomy-kitchens">
<div class="wrapper narrow collapse">
<?php
$args = array(
'post_type' => 'photo',
'posts_per_page' => '15',
'orderby' => 'rand',
@celticwebdesign
celticwebdesign / WordPress loop objects into array
Created July 26, 2016 07:34
WordPress loop objects into array
$args = array(
'post_type' => 'products',
'post_status' => 'publish',
'posts_per_page' => -1
);
$child_query = new WP_Query($args);
$brands_array = [];
@celticwebdesign
celticwebdesign / WordPress Single Post - Previous Next Articles
Created August 7, 2016 20:51
WordPress Single Post - Previous Next Articles
<!-- prev post next -->
<div class="prev_next clear">
<div class="left prev">
<?php
previous_post_link('&laquo; %link','Previous post');
?>
</div>
<div class="right next">
<?php
next_post_link('%link &raquo;','Next post');
@celticwebdesign
celticwebdesign / Dev Template Name 2
Last active February 8, 2017 09:49
Now uses wp_footer hook.
HTML ------
NONE
HTML ------
PHP functions.php ------
@celticwebdesign
celticwebdesign / WordPress - get attachment by name and display in page
Created August 12, 2016 10:37
WordPress - get attachment by url parameter and display in page
http://xxx.com/race-results/?series=Attachment_Name_Here.html
if( isset( $_GET['series'] ) ) {
function get_attachment_url_by_slug( $slug ) {
$args = array(