Skip to content

Instantly share code, notes, and snippets.

View cphilippsen's full-sized avatar

Christian Philippsen cphilippsen

View GitHub Profile
@cphilippsen
cphilippsen / pagination.php
Created January 21, 2015 15:02
WordPress Pagination on single.php from the same category and/or taxonomy
<div id="pagination">
<?php
$prev_post = get_previous_post(true, '', 'taxonomy');
$next_post = get_next_post(true, '', 'taxonomy');
?>
<?php if (!empty( $prev_post )): ?>
<div class="prev">
<a href="<?php echo get_permalink( $prev_post->ID ); ?>">
$(document).ready(function(){
$('a#nav-btn').click(function() {
$(this).toggleClass('nav-btn-active');
$('#nav').stop().slideToggle(200).toggleClass('nav-active');
return false;
});
$('a#login-btn').click(function() {
$(this).toggleClass('login-btn-active');
@cphilippsen
cphilippsen / gist:3930169
Created October 22, 2012 07:44
WP_Query loop with Custom Post Type
$movies = new WP_Query(
array(
'post_type' => 'movie_reviews',
'order' => 'DESC',
'orderby' => 'date'
)
);
<?php while ( $movies->have_posts() ) : $movies->the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
@cphilippsen
cphilippsen / acf_relationship_fields
Created April 8, 2012 15:48
ACF Relationship get related posts fields content
<?php if(get_field('relationship')): ?>
<h2>Related posts</h2>
<ul id="portfolio-grid">
<?php foreach(get_field('relationship') as $related): ?>
<li>
<a href="<?php echo get_permalink($related->ID); ?>" title="<?php echo get_the_title($related->ID) ?>">
<img src="<?php the_field('image_src', $related->ID); ?>" alt="" /> <span class="caption"><?php the_field('image_caption', $related->ID); ?></span>
</a>
</li>