Skip to content

Instantly share code, notes, and snippets.

View celticwebdesign's full-sized avatar

Darren Stevens celticwebdesign

View GitHub Profile
<?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',
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;
$('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);
@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);
@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 adjust loop query
Created April 15, 2016 13:21
WordPress adjust loop query - used on FHC search.php
<?php
global $query_string;
query_posts($query_string . "&post_type=document");
?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
@celticwebdesign
celticwebdesign / Get a post of parent category
Created March 22, 2016 21:35
Get a post of parent category (of another post)
<?php
$category = get_the_category();
// echo $category[0]->category_parent;
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
'post__not_in' => array( get_the_ID() ),
@celticwebdesign
celticwebdesign / Add box shadow to header on scroll
Created March 21, 2016 11:17
Add box shadow to header on scroll
$( window ).scroll(function() {
// if ($('body').not('.home').length > 0 ) {
if( $(window).scrollTop() > 0 ) {
$('#header').css('box-shadow', '0 1px 3px rgba(0, 0, 0, 0.5)');
} else {
$('#header').css('box-shadow', 'none');
}
// }
});
@celticwebdesign
celticwebdesign / PhotoSwipe - Object Passing - WordPress
Created March 5, 2016 12:04
Passing an object through JSON from PHP to JS, to use in PhotoSwipe.js. Allows different photo widths and heights in PhotoSwipe lightbox. See 'View image gallery' on littlewhitealice.co.uk/our-cottages/fearn-the-alder-house/
Passing an object through JSON from PHP to JS, to use in PhotoSwipe.js
Allows different photo widths and heights in PhotoSwipe lightbox
See 'View image gallery' on littlewhitealice.co.uk/our-cottages/fearn-the-alder-house/
---- HTML
$output .= "<div class='flexslider'>
<ul class='slides'>";
<?php
global $post;
$author_id=$post->post_author;
// echo gettype( $author_id );
// echo "<pre>";
// print_r( $author_id );
// echo "</pre>";
// https://codex.wordpress.org/Function_Reference/the_author_meta