Skip to content

Commit

Permalink
Added compatibility with Post Order Plugin
Browse files Browse the repository at this point in the history
The post order plugin which I recommend to use, ironically would break
the home page popular articles widget. Made a patch which fixes the
issue.
  • Loading branch information
swashata committed Oct 10, 2013
1 parent 8cf9a9b commit b4661b1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion home.php
Expand Up @@ -145,12 +145,21 @@
</div>
<?php // Popular posts ?>
<?php
// Remove the filter from the Posts Order By Plugin
if ( function_exists( 'CPTOrderPosts' ) ) {
remove_filter( 'posts_orderby', 'CPTOrderPosts', 99, 2 );
}

// Prep the arguments
$args = array(
'post_type' => 'post',
'posts_per_page' => get_option( 'posts_per_page', 5 ),
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_key' => 'ipt_kb_like_article',
'orderby' => 'meta_value_num',
);

// Build our custom query
$popular_query = new WP_Query( $args );
?>
<div class="col-md-6">
Expand All @@ -174,6 +183,12 @@
</div>

<?php wp_reset_query(); ?>
<?php
// Add the filter from the Posts Order By Plugin
if ( function_exists( 'CPTOrderPosts' ) ) {
add_filter( 'posts_orderby', 'CPTOrderPosts', 99, 2 );
}
?>

</main><!-- #main -->
</div><!-- #primary -->
Expand Down

1 comment on commit b4661b1

@alessandropellegrini
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must definitely thank you. This commit has saved me hours of working, trying to do the exact same thing you are doing in your theme!

Please sign in to comment.