Skip to content

Instantly share code, notes, and snippets.

@Aziz-Rahman
Created December 2, 2015 04:38
Show Gist options
  • Save Aziz-Rahman/df8cef1a0ede1efd2e5c to your computer and use it in GitHub Desktop.
Save Aziz-Rahman/df8cef1a0ede1efd2e5c to your computer and use it in GitHub Desktop.
Displayrelated post by taxonomy tag
<?php
// Get taxonomy tags
$taxonomy = 'photo-tag';
$terms = get_terms($taxonomy);
shuffle($terms);
if ($terms) {
foreach($terms as $term) {
$tags = $term->slug;
}
}
$args = array(
'post_type' => 'photo',
'post_status' => 'publish',
'photo-tag' => $tags, // display by tag
'orderby' => 'rand',
'post__not_in' => array( get_the_ID() ),
'posts_per_page' => 6
);
// etc ...
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment