Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
Created April 28, 2011 07:44
Show Gist options
  • Save mrlannigan/945978 to your computer and use it in GitHub Desktop.
Save mrlannigan/945978 to your computer and use it in GitHub Desktop.
WPquestions.com #2150 rev3
<?php //answer to wpquestions.com #2150 by Julian Lannigan (julianlannigan.com)
function article_series() {
global $post;
$series = get_post_meta($post->ID, 'edit_cat', true);
$currentPost = $post;
if ($series) {
$args = array(
'numberposts' => 5,
'meta_key' => 'edit_cat',
'meta_value' => $series,
);
$series_posts = get_posts($args);
if ($series_posts) {
echo '<div id="dshop-latest-list"><h4 class="series-title">' . __('More like this') . '</h4><ul>';
foreach($series_posts as $post) {
setup_postdata($post);
$post_title = str_replace('"', '"', $post->post_title);
$image_link = get_post_image($post);
if($post->ID != $currentPost->ID) { //Will not show the current post
echo '<li><img style="margin:0px 10px 10px 0px; height: 100px; width: 100px; display: block; float:left;" src="' . $image_link . '" alt="All the latest"/>';
echo '<a href="' . get_permalink($post->ID) . '" title="' . $post_title . '">' . $post_title . '</a></li>';
}
}
echo '</ul></div>';
}
}
}
function related_cat_edit() {
if (is_single() && in_category('4008')) {
article_series();
}
}
add_action('thesis_hook_after_post', 'related_cat_edit');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment