Before you ask please READ THIS

(New) Random Posts Widget

edited June 2013 in Hypershot Posts: 40
Hi guys,
for I was missing this feature, I added it :) It's a alteration of the already existing widgets of the theme.

Just add the code snippet attached in your widgets.php between
register_widget('Apollo13_Widget_Popular_Posts');
and
class Apollo13_Widget_Related_Posts extends WP_Widget {
Oh, and if you want to show only random posts of a certain category change
$r = new WP_Query(array($search_string => $__search,'post__not_in' => array($post->ID), 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
to
$r = new WP_Query(array($search_string => $__search,'post__not_in' => array($post->ID), 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'category_name' => 'PUT_YOUR_CATEGORY_NAME_HERE'));
in the attached snippet.

Max

P.S.: This randomness only works properly, if NO page caching plugin is enabled (There are ways, to exclude widgets from caching, but that's too much work to alter :) )
Regards,
Max
Post edited by macmacs on

Comments

  • AirAir
    Posts: 10,970
    Wow very nice :-) I am marking this one, and will add it to HS when update time will come:-)
    There are not many such nice users as you :-) Thanks!

    With regards.
  • Posts: 40
    You're welcome! It's just an addition to a great theme :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion